<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>User's Guide</title>
<link rel="stylesheet" href="../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset">
<link rel="up" href="../accumulators.html" title="Chapter 1. Boost.Accumulators">
<link rel="prev" href="../accumulators.html" title="Chapter 1. Boost.Accumulators">
<link rel="next" href="acknowledgements.html" title="Acknowledgements">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td>
<td align="center"><a href="../../../index.html">Home</a></td>
<td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../accumulators.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../accumulators.html"><img src="../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="acknowledgements.html"><img src="../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="accumulators.user_s_guide"></a><a class="link" href="user_s_guide.html" title="User's Guide">User's Guide</a>
</h2></div></div></div>
<div class="toc"><dl class="toc">
<dt><span class="section"><a href="user_s_guide.html#accumulators.user_s_guide.the_accumulators_framework">The
      Accumulators Framework</a></span></dt>
<dt><span class="section"><a href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library">The
      Statistical Accumulators Library</a></span></dt>
</dl></div>
<p>
      This section describes how to use the Boost.Accumulators framework to create
      new accumulators and how to use the existing statistical accumulators to perform
      incremental statistical computation. For detailed information regarding specific
      components in Boost.Accumulators, check the <a class="link" href="reference.html#accumulators_framework_reference" title="Accumulators Framework Reference">Reference</a>
      section.
    </p>
<h3>
<a name="accumulators.user_s_guide.h0"></a>
      <span class="phrase"><a name="accumulators.user_s_guide.hello__world_"></a></span><a class="link" href="user_s_guide.html#accumulators.user_s_guide.hello__world_">Hello,
      World!</a>
    </h3>
<p>
      Below is a complete example of how to use the Accumulators Framework and the
      Statistical Accumulators to perform an incremental statistical calculation.
      It calculates the mean and 2nd moment of a sequence of doubles.
    </p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">iostream</span><span class="special">&gt;</span>
<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">accumulators</span><span class="special">/</span><span class="identifier">accumulators</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">accumulators</span><span class="special">/</span><span class="identifier">statistics</span><span class="special">/</span><span class="identifier">stats</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">accumulators</span><span class="special">/</span><span class="identifier">statistics</span><span class="special">/</span><span class="identifier">mean</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">accumulators</span><span class="special">/</span><span class="identifier">statistics</span><span class="special">/</span><span class="identifier">moment</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
<span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">accumulators</span><span class="special">;</span>

<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span>
<span class="special">{</span>
    <span class="comment">// Define an accumulator set for calculating the mean and the</span>
    <span class="comment">// 2nd moment ...</span>
    <span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">mean</span><span class="special">,</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">moment</span><span class="special">&lt;</span><span class="number">2</span><span class="special">&gt;</span> <span class="special">&gt;</span> <span class="special">&gt;</span> <span class="identifier">acc</span><span class="special">;</span>

    <span class="comment">// push in some data ...</span>
    <span class="identifier">acc</span><span class="special">(</span><span class="number">1.2</span><span class="special">);</span>
    <span class="identifier">acc</span><span class="special">(</span><span class="number">2.3</span><span class="special">);</span>
    <span class="identifier">acc</span><span class="special">(</span><span class="number">3.4</span><span class="special">);</span>
    <span class="identifier">acc</span><span class="special">(</span><span class="number">4.5</span><span class="special">);</span>

    <span class="comment">// Display the results ...</span>
    <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"Mean:   "</span> <span class="special">&lt;&lt;</span> <span class="identifier">mean</span><span class="special">(</span><span class="identifier">acc</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
    <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"Moment: "</span> <span class="special">&lt;&lt;</span> <span class="identifier">moment</span><span class="special">&lt;</span><span class="number">2</span><span class="special">&gt;(</span><span class="identifier">acc</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>

    <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span>
<span class="special">}</span>
</pre>
<p>
      This program displays the following:
    </p>
<pre class="programlisting">Mean:   2.85
Moment: 9.635
</pre>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="accumulators.user_s_guide.the_accumulators_framework"></a><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_accumulators_framework" title="The Accumulators Framework">The
      Accumulators Framework</a>
</h3></div></div></div>
<div class="toc"><dl class="toc">
<dt><span class="section"><a href="user_s_guide.html#accumulators.user_s_guide.the_accumulators_framework.using___accumulator_set___">Using
        <code class="literal">accumulator_set&lt;&gt;</code></a></span></dt>
<dt><span class="section"><a href="user_s_guide.html#accumulators.user_s_guide.the_accumulators_framework.extracting_results">Extracting
        Results</a></span></dt>
<dt><span class="section"><a href="user_s_guide.html#accumulators.user_s_guide.the_accumulators_framework.passing_optional_parameters">Passing
        Optional Parameters</a></span></dt>
<dt><span class="section"><a href="user_s_guide.html#accumulators.user_s_guide.the_accumulators_framework.weighted_samples">Weighted
        Samples</a></span></dt>
<dt><span class="section"><a href="user_s_guide.html#accumulators.user_s_guide.the_accumulators_framework.numeric_operators_sub_library">Numeric
        Operators Sub-Library</a></span></dt>
<dt><span class="section"><a href="user_s_guide.html#accumulators.user_s_guide.the_accumulators_framework.extending_the_accumulators_framework">Extending
        the Accumulators Framework</a></span></dt>
<dt><span class="section"><a href="user_s_guide.html#accumulators.user_s_guide.the_accumulators_framework.concepts">Concepts</a></span></dt>
</dl></div>
<p>
        The Accumulators Framework is framework for performing incremental calculations.
        Usage of the framework follows the following pattern:
      </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
            Users build a computational object, called an <span class="emphasis"><em><code class="computeroutput"><a class="link" href="../boost/accumulators/accumulator_set.html" title="Struct template accumulator_set">accumulator_set&lt;&gt;</a></code></em></span>,
            by selecting the computations in which they are interested, or authoring
            their own computational primitives which fit within the framework.
          </li>
<li class="listitem">
            Users push data into the <code class="computeroutput"><a class="link" href="../boost/accumulators/accumulator_set.html" title="Struct template accumulator_set">accumulator_set&lt;&gt;</a></code>
            object one sample at a time.
          </li>
<li class="listitem">
            The <code class="computeroutput"><a class="link" href="../boost/accumulators/accumulator_set.html" title="Struct template accumulator_set">accumulator_set&lt;&gt;</a></code>
            computes the requested quantities in the most efficient method possible,
            resolving dependencies between requested calculations, possibly caching
            intermediate results.
          </li>
</ul></div>
<p>
        The Accumulators Framework defines the utilities needed for defining primitive
        computational elements, called <span class="emphasis"><em>accumulators</em></span>. It also
        provides the <code class="computeroutput"><a class="link" href="../boost/accumulators/accumulator_set.html" title="Struct template accumulator_set">accumulator_set&lt;&gt;</a></code>
        type, described above.
      </p>
<h3>
<a name="accumulators.user_s_guide.the_accumulators_framework.h0"></a>
        <span class="phrase"><a name="accumulators.user_s_guide.the_accumulators_framework.terminology"></a></span><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_accumulators_framework.terminology">Terminology</a>
      </h3>
<p>
        The following terms are used in the rest of the documentation.
      </p>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Sample</span></dt>
<dd><p>
              <a name="sample_type"></a>A datum that is pushed into an <code class="computeroutput"><a class="link" href="../boost/accumulators/accumulator_set.html" title="Struct template accumulator_set">accumulator_set&lt;&gt;</a></code>. The type of the
              sample is the <span class="emphasis"><em>sample type</em></span>.
            </p></dd>
<dt><span class="term">Weight</span></dt>
<dd><p>
              <a name="weight_type"></a>An optional scalar value passed along with
              the sample specifying the weight of the sample. Conceptually, each
              sample is multiplied with its weight. The type of the weight is the
              <span class="emphasis"><em>weight type</em></span>.
            </p></dd>
<dt><span class="term">Feature</span></dt>
<dd><p>
              An abstract primitive computational entity. When defining an <code class="computeroutput"><a class="link" href="../boost/accumulators/accumulator_set.html" title="Struct template accumulator_set">accumulator_set&lt;&gt;</a></code>, users specify
              the features in which they are interested, and the <code class="computeroutput"><a class="link" href="../boost/accumulators/accumulator_set.html" title="Struct template accumulator_set">accumulator_set&lt;&gt;</a></code>
              figures out which <span class="emphasis"><em>accumulators</em></span> would best provide
              those features. Features may depend on other features. If they do,
              the accumulator set figures out which accumulators to add to satisfy
              the dependencies.
            </p></dd>
<dt><span class="term">Accumulator</span></dt>
<dd><p>
              A concrete primitive computational entity. An accumulator is a concrete
              implementation of a feature. It satisfies exactly one abstract feature.
              Several different accumulators may provide the same feature, but may
              represent different implementation strategies.
            </p></dd>
<dt><span class="term">Accumulator Set</span></dt>
<dd><p>
              A collection of accumulators. An accumulator set is specified with
              a sample type and a list of features. The accumulator set uses this
              information to generate an ordered set of accumulators depending on
              the feature dependency graph. An accumulator set accepts samples one
              datum at a time, propagating them to each accumulator in order. At
              any point, results can be extracted from the accumulator set.
            </p></dd>
<dt><span class="term">Extractor</span></dt>
<dd><p>
              A function or function object that can be used to extract a result
              from an <code class="computeroutput"><a class="link" href="../boost/accumulators/accumulator_set.html" title="Struct template accumulator_set">accumulator_set&lt;&gt;</a></code>.
            </p></dd>
</dl>
</div>
<h3>
<a name="accumulators.user_s_guide.the_accumulators_framework.h1"></a>
        <span class="phrase"><a name="accumulators.user_s_guide.the_accumulators_framework.overview"></a></span><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_accumulators_framework.overview">Overview</a>
      </h3>
<p>
        Here is a list of the important types and functions in the Accumulator Framework
        and a brief description of each.
      </p>
<div class="table">
<a name="accumulators.user_s_guide.the_accumulators_framework.t0"></a><p class="title"><b>Table 1.1. Accumulators Toolbox</b></p>
<div class="table-contents"><table class="table" summary="Accumulators Toolbox">
<colgroup>
<col>
<col>
</colgroup>
<thead><tr>
<th>
                <p>
                  Tool
                </p>
              </th>
<th>
                <p>
                  Description
                </p>
              </th>
</tr></thead>
<tbody>
<tr>
<td>
                <p>
                  <code class="computeroutput"><a class="link" href="../boost/accumulators/accumulator_set.html" title="Struct template accumulator_set">accumulator_set&lt;&gt;</a></code>
                </p>
              </td>
<td>
                <p>
                  This is the most important type in the Accumulators Framework.
                  It is a collection of accumulators. A datum pushed into an <code class="computeroutput"><a class="link" href="../boost/accumulators/accumulator_set.html" title="Struct template accumulator_set">accumulator_set&lt;&gt;</a></code> is forwarded
                  to each accumulator, in an order determined by the dependency relationships
                  between the accumulators. Computational results can be extracted
                  from an accumulator at any time.
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  <code class="computeroutput"><a class="link" href="../boost/accumulators/depends_on.html" title="Struct template depends_on">depends_on&lt;&gt;</a></code>
                </p>
              </td>
<td>
                <p>
                  Used to specify which other features a feature depends on.
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  <code class="computeroutput"><a class="link" href="../boost/accumulators/feature_of.html" title="Struct template feature_of">feature_of&lt;&gt;</a></code>
                </p>
              </td>
<td>
                <p>
                  Trait used to tell the Accumulators Framework that, for the purpose
                  of feature-based dependency resolution, one feature should be treated
                  the same as another.
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  <code class="computeroutput"><a class="link" href="../boost/accumulators/as_feature.html" title="Struct template as_feature">as_feature&lt;&gt;</a></code>
                </p>
              </td>
<td>
                <p>
                  Used to create an alias for a feature. For example, if there are
                  two features, fast_X and accurate_X, they can be mapped to X(fast)
                  and X(accurate) with <code class="computeroutput"><a class="link" href="../boost/accumulators/as_feature.html" title="Struct template as_feature">as_feature&lt;&gt;</a></code>.
                  This is just syntactic sugar.
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  <code class="computeroutput"><a class="link" href="../boost/accumulators/features.html" title="Struct template features">features&lt;&gt;</a></code>
                </p>
              </td>
<td>
                <p>
                  An <a href="../../../libs/mpl/index.html" target="_top">MPL</a> sequence.
                  We can use <code class="computeroutput"><a class="link" href="../boost/accumulators/features.html" title="Struct template features">features&lt;&gt;</a></code>
                  as the second template parameter when declaring an <code class="computeroutput"><a class="link" href="../boost/accumulators/accumulator_set.html" title="Struct template accumulator_set">accumulator_set&lt;&gt;</a></code>.
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  <code class="computeroutput">external&lt;&gt;</code>
                </p>
              </td>
<td>
                <p>
                  Used when declaring an <code class="computeroutput"><a class="link" href="../boost/accumulators/accumulator_set.html" title="Struct template accumulator_set">accumulator_set&lt;&gt;</a></code>.
                  If the weight type is specified with <code class="computeroutput">external&lt;&gt;</code>,
                  then the weight accumulators are assumed to reside in a separate
                  accumulator set which will be passed in with a named parameter.
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  <code class="computeroutput">extractor&lt;&gt;</code>
                </p>
              </td>
<td>
                <p>
                  A class template useful for creating an extractor function object.
                  It is parameterized on a feature, and it has member functions for
                  extracting from an <code class="computeroutput"><a class="link" href="../boost/accumulators/accumulator_set.html" title="Struct template accumulator_set">accumulator_set&lt;&gt;</a></code>
                  the result corresponding to that feature.
                </p>
              </td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break"><div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="accumulators.user_s_guide.the_accumulators_framework.using___accumulator_set___"></a><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_accumulators_framework.using___accumulator_set___" title="Using accumulator_set&lt;&gt;">Using
        <code class="literal">accumulator_set&lt;&gt;</code></a>
</h4></div></div></div>
<p>
          Our tour of the <code class="computeroutput"><a class="link" href="../boost/accumulators/accumulator_set.html" title="Struct template accumulator_set">accumulator_set&lt;&gt;</a></code>
          class template begins with the forward declaration:
        </p>
<pre class="programlisting"><span class="keyword">template</span><span class="special">&lt;</span> <span class="keyword">typename</span> <span class="identifier">Sample</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">Features</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">Weight</span> <span class="special">=</span> <span class="keyword">void</span> <span class="special">&gt;</span>
<span class="keyword">struct</span> <span class="identifier">accumulator_set</span><span class="special">;</span>
</pre>
<p>
          The template parameters have the following meaning:
        </p>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term"><code class="computeroutput"><span class="identifier">Sample</span></code></span></dt>
<dd><p>
                The type of the data that will be accumulated.
              </p></dd>
<dt><span class="term"><code class="computeroutput"><span class="identifier">Features</span></code></span></dt>
<dd><p>
                An <a href="../../../libs/mpl/index.html" target="_top">MPL</a> sequence of
                features to be calculated.
              </p></dd>
<dt><span class="term"><code class="computeroutput"><span class="identifier">Weight</span></code></span></dt>
<dd><p>
                The type of the (optional) weight paramter.
              </p></dd>
</dl>
</div>
<p>
          For example, the following line declares an <code class="computeroutput"><a class="link" href="../boost/accumulators/accumulator_set.html" title="Struct template accumulator_set">accumulator_set&lt;&gt;</a></code>
          that will accept a sequence of doubles one at a time and calculate the
          min and mean:
        </p>
<pre class="programlisting"><span class="identifier">accumulator_set</span><span class="special">&lt;</span> <span class="keyword">double</span><span class="special">,</span> <span class="identifier">features</span><span class="special">&lt;</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">min</span><span class="special">,</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">mean</span> <span class="special">&gt;</span> <span class="special">&gt;</span> <span class="identifier">acc</span><span class="special">;</span>
</pre>
<p>
          Notice that we use the <code class="computeroutput"><a class="link" href="../boost/accumulators/features.html" title="Struct template features">features&lt;&gt;</a></code>
          template to specify a list of features to be calculated. <code class="computeroutput"><a class="link" href="../boost/accumulators/features.html" title="Struct template features">features&lt;&gt;</a></code>
          is an MPL sequence of features.
        </p>
<div class="note"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../doc/src/images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>
            <code class="computeroutput"><a class="link" href="../boost/accumulators/features.html" title="Struct template features">features&lt;&gt;</a></code> is a synonym of
            <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;&gt;</span></code>.
            In fact, we could use <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;&gt;</span></code> or any MPL sequence if we prefer,
            and the meaning would be the same.
          </p></td></tr>
</table></div>
<p>
          Once we have defined an <code class="computeroutput"><a class="link" href="../boost/accumulators/accumulator_set.html" title="Struct template accumulator_set">accumulator_set&lt;&gt;</a></code>,
          we can then push data into it, and it will calculate the quantities you
          requested, as shown below.
        </p>
<pre class="programlisting"><span class="comment">// push some data into the accumulator_set ...</span>
<span class="identifier">acc</span><span class="special">(</span><span class="number">1.2</span><span class="special">);</span>
<span class="identifier">acc</span><span class="special">(</span><span class="number">2.3</span><span class="special">);</span>
<span class="identifier">acc</span><span class="special">(</span><span class="number">3.4</span><span class="special">);</span>
</pre>
<p>
          Since <code class="computeroutput"><a class="link" href="../boost/accumulators/accumulator_set.html" title="Struct template accumulator_set">accumulator_set&lt;&gt;</a></code>
          defines its accumulate function to be the function call operator, we might
          be tempted to use an <code class="computeroutput"><a class="link" href="../boost/accumulators/accumulator_set.html" title="Struct template accumulator_set">accumulator_set&lt;&gt;</a></code>
          as a UnaryFunction to a standard algorithm such as <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">for_each</span></code>.
          That's fine as long as we keep in mind that the standard algorithms take
          UnaryFunction objects by value, which involves making a copy of the <code class="computeroutput"><a class="link" href="../boost/accumulators/accumulator_set.html" title="Struct template accumulator_set">accumulator_set&lt;&gt;</a></code> object. Consider the
          following:
        </p>
<pre class="programlisting"><span class="comment">// The data for which we wish to calculate statistical properties:</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="keyword">double</span> <span class="special">&gt;</span> <span class="identifier">data</span><span class="special">(</span> <span class="comment">/* stuff */</span> <span class="special">);</span>

<span class="comment">// The accumulator set which will calculate the properties for us:    </span>
<span class="identifier">accumulator_set</span><span class="special">&lt;</span> <span class="keyword">double</span><span class="special">,</span> <span class="identifier">features</span><span class="special">&lt;</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">min</span><span class="special">,</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">mean</span> <span class="special">&gt;</span> <span class="special">&gt;</span> <span class="identifier">acc</span><span class="special">;</span>

<span class="comment">// Use std::for_each to accumulate the statistical properties:</span>
<span class="identifier">acc</span> <span class="special">=</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">for_each</span><span class="special">(</span> <span class="identifier">data</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">data</span><span class="special">.</span><span class="identifier">end</span><span class="special">(),</span> <span class="identifier">acc</span> <span class="special">);</span>
</pre>
<p>
          Notice how we must assign the return value of <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">for_each</span></code>
          back to the <code class="computeroutput"><a class="link" href="../boost/accumulators/accumulator_set.html" title="Struct template accumulator_set">accumulator_set&lt;&gt;</a></code>.
          This works, but some accumulators are not cheap to copy. For example, the
          <code class="computeroutput"><a class="link" href="../boost/accumulators/tag/tail.html" title="Struct template tail">tail</a></code>
          and <code class="computeroutput"><a class="link" href="../boost/accumulators/tag/tail_variate.html" title="Struct template tail_variate">tail_variate&lt;&gt;</a></code>
          accumulators must store a <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;&gt;</span></code>, so copying these accumulators
          involves a dynamic allocation. We might be better off in this case passing
          the accumulator by reference, with the help of <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">bind</span><span class="special">()</span></code> and <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">ref</span><span class="special">()</span></code>. See below:
        </p>
<pre class="programlisting"><span class="comment">// The data for which we wish to calculate statistical properties:</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="keyword">double</span> <span class="special">&gt;</span> <span class="identifier">data</span><span class="special">(</span> <span class="comment">/* stuff */</span> <span class="special">);</span>

<span class="comment">// The accumulator set which will calculate the properties for us:</span>
<span class="identifier">accumulator_set</span><span class="special">&lt;</span> <span class="keyword">double</span><span class="special">,</span> <span class="identifier">features</span><span class="special">&lt;</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">tail</span><span class="special">&lt;</span><span class="identifier">left</span><span class="special">&gt;</span> <span class="special">&gt;</span> <span class="special">&gt;</span> <span class="identifier">acc</span><span class="special">(</span>
    <span class="identifier">tag</span><span class="special">::</span><span class="identifier">tail</span><span class="special">&lt;</span><span class="identifier">left</span><span class="special">&gt;::</span><span class="identifier">cache_size</span> <span class="special">=</span> <span class="number">4</span> <span class="special">);</span>

<span class="comment">// Use std::for_each to accumulate the statistical properties:</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">for_each</span><span class="special">(</span> <span class="identifier">data</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">data</span><span class="special">.</span><span class="identifier">end</span><span class="special">(),</span> <span class="identifier">bind</span><span class="special">&lt;</span><span class="keyword">void</span><span class="special">&gt;(</span> <span class="identifier">ref</span><span class="special">(</span><span class="identifier">acc</span><span class="special">),</span> <span class="identifier">_1</span> <span class="special">)</span> <span class="special">);</span>
</pre>
<p>
          Notice now that we don't care about the return value of <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">for_each</span><span class="special">()</span></code> anymore because <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">for_each</span><span class="special">()</span></code> is modifying <code class="computeroutput"><span class="identifier">acc</span></code>
          directly.
        </p>
<div class="note"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../doc/src/images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>
            To use <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">bind</span><span class="special">()</span></code>
            and <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">ref</span><span class="special">()</span></code>,
            you must <code class="computeroutput"><span class="preprocessor">#include</span></code>
            <code class="literal">&lt;boost/bind.hpp&gt;</code> and <code class="literal">&lt;boost/ref.hpp&gt;</code>
          </p></td></tr>
</table></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="accumulators.user_s_guide.the_accumulators_framework.extracting_results"></a><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_accumulators_framework.extracting_results" title="Extracting Results">Extracting
        Results</a>
</h4></div></div></div>
<p>
          Once we have declared an <code class="computeroutput"><a class="link" href="../boost/accumulators/accumulator_set.html" title="Struct template accumulator_set">accumulator_set&lt;&gt;</a></code>
          and pushed data into it, we need to be able to extract results from it.
          For each feature we can add to an <code class="computeroutput"><a class="link" href="../boost/accumulators/accumulator_set.html" title="Struct template accumulator_set">accumulator_set&lt;&gt;</a></code>,
          there is a corresponding extractor for fetching its result. Usually, the
          extractor has the same name as the feature, but in a different namespace.
          For example, if we accumulate the <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">min</span></code>
          and <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">max</span></code> features, we can extract the results
          with the <code class="computeroutput"><span class="identifier">min</span></code> and <code class="computeroutput"><span class="identifier">max</span></code> extractors, as follows:
        </p>
<pre class="programlisting"><span class="comment">// Calculate the minimum and maximum for a sequence of integers.</span>
<span class="identifier">accumulator_set</span><span class="special">&lt;</span> <span class="keyword">int</span><span class="special">,</span> <span class="identifier">features</span><span class="special">&lt;</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">min</span><span class="special">,</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">max</span> <span class="special">&gt;</span> <span class="special">&gt;</span> <span class="identifier">acc</span><span class="special">;</span>
<span class="identifier">acc</span><span class="special">(</span> <span class="number">2</span> <span class="special">);</span>
<span class="identifier">acc</span><span class="special">(</span> <span class="special">-</span><span class="number">1</span> <span class="special">);</span>
<span class="identifier">acc</span><span class="special">(</span> <span class="number">1</span> <span class="special">);</span>

<span class="comment">// This displays "(-1, 2)"</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="char">'('</span> <span class="special">&lt;&lt;</span> <span class="identifier">min</span><span class="special">(</span> <span class="identifier">acc</span> <span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="string">", "</span> <span class="special">&lt;&lt;</span> <span class="identifier">max</span><span class="special">(</span> <span class="identifier">acc</span> <span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="string">")\n"</span><span class="special">;</span>
</pre>
<p>
          The extractors are all declared in the <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">accumulators</span><span class="special">::</span><span class="identifier">extract</span></code>
          namespace, but they are brought into the <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">accumulators</span></code>
          namespace with a <code class="computeroutput"><span class="keyword">using</span></code> declaration.
        </p>
<div class="tip"><table border="0" summary="Tip">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="../../../doc/src/images/tip.png"></td>
<th align="left">Tip</th>
</tr>
<tr><td align="left" valign="top"><p>
            On the Windows platform, <code class="computeroutput"><span class="identifier">min</span></code>
            and <code class="computeroutput"><span class="identifier">max</span></code> are preprocessor
            macros defined in <code class="literal">WinDef.h</code>. To use the <code class="computeroutput"><span class="identifier">min</span></code> and <code class="computeroutput"><span class="identifier">max</span></code>
            extractors, you should either compile with <code class="computeroutput"><span class="identifier">NOMINMAX</span></code>
            defined, or you should invoke the extractors like: <code class="computeroutput"><span class="special">(</span><span class="identifier">min</span><span class="special">)(</span> <span class="identifier">acc</span> <span class="special">)</span></code>
            and <code class="computeroutput"><span class="special">(</span><span class="identifier">max</span><span class="special">)(</span> <span class="identifier">acc</span> <span class="special">)</span></code>. The parentheses keep the macro from
            being invoked.
          </p></td></tr>
</table></div>
<p>
          Another way to extract a result from an <code class="computeroutput"><a class="link" href="../boost/accumulators/accumulator_set.html" title="Struct template accumulator_set">accumulator_set&lt;&gt;</a></code>
          is with the <code class="computeroutput"><span class="identifier">extract_result</span><span class="special">()</span></code> function. This can be more convenient
          if there isn't an extractor object handy for a certain feature. The line
          above which displays results could equally be written as:
        </p>
<pre class="programlisting"><span class="comment">// This displays "(-1, 2)"</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="char">'('</span>  <span class="special">&lt;&lt;</span> <span class="identifier">extract_result</span><span class="special">&lt;</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">min</span> <span class="special">&gt;(</span> <span class="identifier">acc</span> <span class="special">)</span>
          <span class="special">&lt;&lt;</span> <span class="string">", "</span> <span class="special">&lt;&lt;</span> <span class="identifier">extract_result</span><span class="special">&lt;</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">max</span> <span class="special">&gt;(</span> <span class="identifier">acc</span> <span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="string">")\n"</span><span class="special">;</span>
</pre>
<p>
          Finally, we can define our own extractor using the <code class="computeroutput">extractor&lt;&gt;</code>
          class template. For instance, another way to avoid the <code class="computeroutput"><span class="identifier">min</span></code>
          / <code class="computeroutput"><span class="identifier">max</span></code> macro business would
          be to define extractors with names that don't conflict with the macros,
          like this:
        </p>
<pre class="programlisting"><span class="identifier">extractor</span><span class="special">&lt;</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">min</span> <span class="special">&gt;</span> <span class="identifier">min_</span><span class="special">;</span>
<span class="identifier">extractor</span><span class="special">&lt;</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">min</span> <span class="special">&gt;</span> <span class="identifier">max_</span><span class="special">;</span>

<span class="comment">// This displays "(-1, 2)"</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="char">'('</span> <span class="special">&lt;&lt;</span> <span class="identifier">min_</span><span class="special">(</span> <span class="identifier">acc</span> <span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="string">", "</span> <span class="special">&lt;&lt;</span> <span class="identifier">max_</span><span class="special">(</span> <span class="identifier">acc</span> <span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="string">")\n"</span><span class="special">;</span>
</pre>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="accumulators.user_s_guide.the_accumulators_framework.passing_optional_parameters"></a><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_accumulators_framework.passing_optional_parameters" title="Passing Optional Parameters">Passing
        Optional Parameters</a>
</h4></div></div></div>
<p>
          Some accumulators need initialization parameters. In addition, perhaps
          some auxiliary information needs to be passed into the <code class="computeroutput"><a class="link" href="../boost/accumulators/accumulator_set.html" title="Struct template accumulator_set">accumulator_set&lt;&gt;</a></code>
          along with each sample. Boost.Accumulators handles these cases with named
          parameters from the <a href="../../../libs/parameter/index.html" target="_top">Boost.Parameter</a>
          library.
        </p>
<p>
          For example, consider the <code class="computeroutput"><a class="link" href="../boost/accumulators/tag/tail.html" title="Struct template tail">tail</a></code> and <code class="computeroutput"><a class="link" href="../boost/accumulators/tag/tail_variate.html" title="Struct template tail_variate">tail_variate&lt;&gt;</a></code>
          features. <code class="computeroutput"><a class="link" href="../boost/accumulators/tag/tail.html" title="Struct template tail">tail</a></code> keeps an ordered list
          of the largest <code class="literal"><span class="emphasis"><em>N</em></span></code> samples, where
          <code class="literal"><span class="emphasis"><em>N</em></span></code> can be specified at construction
          time. Also, the <code class="computeroutput"><a class="link" href="../boost/accumulators/tag/tail_variate.html" title="Struct template tail_variate">tail_variate&lt;&gt;</a></code>
          feature, which depends on <code class="computeroutput"><a class="link" href="../boost/accumulators/tag/tail.html" title="Struct template tail">tail</a></code>, keeps track of some
          data that is covariate with the <code class="literal"><span class="emphasis"><em>N</em></span></code>
          samples tracked by <code class="computeroutput"><a class="link" href="../boost/accumulators/tag/tail.html" title="Struct template tail">tail</a></code>. The code below shows
          how this all works, and is described in more detail below.
        </p>
<pre class="programlisting"><span class="comment">// Define a feature for tracking covariate data</span>
<span class="keyword">typedef</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">tail_variate</span><span class="special">&lt;</span> <span class="keyword">int</span><span class="special">,</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">covariate1</span><span class="special">,</span> <span class="identifier">left</span> <span class="special">&gt;</span> <span class="identifier">my_tail_variate_tag</span><span class="special">;</span>

<span class="comment">// This will calculate the left tail and my_tail_variate_tag for N == 2</span>
<span class="comment">// using the tag::tail&lt;left&gt;::cache_size named parameter</span>
<span class="identifier">accumulator_set</span><span class="special">&lt;</span> <span class="keyword">double</span><span class="special">,</span> <span class="identifier">features</span><span class="special">&lt;</span> <span class="identifier">my_tail_variate_tag</span> <span class="special">&gt;</span> <span class="special">&gt;</span> <span class="identifier">acc</span><span class="special">(</span>
    <span class="identifier">tag</span><span class="special">::</span><span class="identifier">tail</span><span class="special">&lt;</span><span class="identifier">left</span><span class="special">&gt;::</span><span class="identifier">cache_size</span> <span class="special">=</span> <span class="number">2</span> <span class="special">);</span>

<span class="comment">// push in some samples and some covariates by using </span>
<span class="comment">// the covariate1 named parameter</span>
<span class="identifier">acc</span><span class="special">(</span> <span class="number">1.2</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span>  <span class="number">12</span> <span class="special">);</span>
<span class="identifier">acc</span><span class="special">(</span> <span class="number">2.3</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="special">-</span><span class="number">23</span> <span class="special">);</span>
<span class="identifier">acc</span><span class="special">(</span> <span class="number">3.4</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span>  <span class="number">34</span> <span class="special">);</span>
<span class="identifier">acc</span><span class="special">(</span> <span class="number">4.5</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="special">-</span><span class="number">45</span> <span class="special">);</span>

<span class="comment">// Define an extractor for the my_tail_variate_tag feature</span>
<span class="identifier">extractor</span><span class="special">&lt;</span> <span class="identifier">my_tail_variate_tag</span> <span class="special">&gt;</span> <span class="identifier">my_tail_variate</span><span class="special">;</span>

<span class="comment">// Write the tail statistic to std::cout. This will print "4.5, 3.4, "</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">ostream_iterator</span><span class="special">&lt;</span> <span class="keyword">double</span> <span class="special">&gt;</span> <span class="identifier">dout</span><span class="special">(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span><span class="special">,</span> <span class="string">", "</span> <span class="special">);</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">copy</span><span class="special">(</span> <span class="identifier">tail</span><span class="special">(</span> <span class="identifier">acc</span> <span class="special">).</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">tail</span><span class="special">(</span> <span class="identifier">acc</span> <span class="special">).</span><span class="identifier">end</span><span class="special">(),</span> <span class="identifier">dout</span> <span class="special">);</span>

<span class="comment">// Write the tail_variate statistic to std::cout. This will print "-45, 34, "</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">ostream_iterator</span><span class="special">&lt;</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="identifier">iout</span><span class="special">(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span><span class="special">,</span> <span class="string">", "</span> <span class="special">);</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">copy</span><span class="special">(</span> <span class="identifier">my_tail_variate</span><span class="special">(</span> <span class="identifier">acc</span> <span class="special">).</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">my_tail_variate</span><span class="special">(</span> <span class="identifier">acc</span> <span class="special">).</span><span class="identifier">end</span><span class="special">(),</span> <span class="identifier">iout</span> <span class="special">);</span>
</pre>
<p>
          There are several things to note about the code above. First, notice that
          we didn't have to request that the <code class="computeroutput"><a class="link" href="../boost/accumulators/tag/tail.html" title="Struct template tail">tail</a></code> feature be calculated.
          That is implicit because the <code class="computeroutput"><a class="link" href="../boost/accumulators/tag/tail_variate.html" title="Struct template tail_variate">tail_variate&lt;&gt;</a></code>
          feature depends on the <code class="computeroutput"><a class="link" href="../boost/accumulators/tag/tail.html" title="Struct template tail">tail</a></code> feature. Next, notice
          how the <code class="computeroutput"><span class="identifier">acc</span></code> object is initialized:
          <code class="computeroutput"><span class="identifier">acc</span><span class="special">(</span>
          <span class="identifier">tag</span><span class="special">::</span><span class="identifier">tail</span><span class="special">&lt;</span><span class="identifier">left</span><span class="special">&gt;::</span><span class="identifier">cache_size</span> <span class="special">=</span>
          <span class="number">2</span> <span class="special">)</span></code>.
          Here, <code class="computeroutput"><span class="identifier">cache_size</span></code> is a named
          parameter. It is used to tell the <code class="computeroutput"><a class="link" href="../boost/accumulators/tag/tail.html" title="Struct template tail">tail</a></code> and <code class="computeroutput"><a class="link" href="../boost/accumulators/tag/tail_variate.html" title="Struct template tail_variate">tail_variate&lt;&gt;</a></code>
          accumulators how many samples and covariates to store. Conceptually, every
          construction parameter is made available to every accumulator in an accumulator
          set.
        </p>
<p>
          We also use a named parameter to pass covariate data into the accumulator
          set along with the samples. As with the constructor parameters, all parameters
          to the accumulate function are made available to all the accumulators in
          the set. In this case, only the accumulator for the <code class="computeroutput"><span class="identifier">my_tail_variate</span></code>
          feature would be interested in the value of the <code class="computeroutput"><span class="identifier">covariate1</span></code>
          named parameter.
        </p>
<p>
          We can make one final observation about the example above. Since <code class="computeroutput"><a class="link" href="../boost/accumulators/tag/tail.html" title="Struct template tail">tail</a></code>
          and <code class="computeroutput"><a class="link" href="../boost/accumulators/tag/tail_variate.html" title="Struct template tail_variate">tail_variate&lt;&gt;</a></code>
          are multi-valued features, the result we extract for them is represented
          as an iterator range. That is why we can say <code class="computeroutput"><span class="identifier">tail</span><span class="special">(</span> <span class="identifier">acc</span> <span class="special">).</span><span class="identifier">begin</span><span class="special">()</span></code> and <code class="computeroutput"><span class="identifier">tail</span><span class="special">(</span> <span class="identifier">acc</span> <span class="special">).</span><span class="identifier">end</span><span class="special">()</span></code>.
        </p>
<p>
          Even the extractors can accept named parameters. In a bit, we'll see a
          situation where that is useful.
        </p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="accumulators.user_s_guide.the_accumulators_framework.weighted_samples"></a><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_accumulators_framework.weighted_samples" title="Weighted Samples">Weighted
        Samples</a>
</h4></div></div></div>
<p>
          Some accumulators, statistical accumulators in particular, deal with data
          that are <span class="emphasis"><em>weighted</em></span>. Each sample pushed into the accumulator
          has an associated weight, by which the sample is conceptually multiplied.
          The Statistical Accumulators Library provides an assortment of these weighted
          statistical accumulators. And many unweighted statistical accumulators
          have weighted variants. For instance, the weighted variant of the <code class="computeroutput"><span class="identifier">sum</span></code> accumulator is called <code class="computeroutput"><span class="identifier">weighted_sum</span></code>, and is calculated by accumulating
          all the samples multiplied by their weights.
        </p>
<p>
          To declare an <code class="computeroutput"><a class="link" href="../boost/accumulators/accumulator_set.html" title="Struct template accumulator_set">accumulator_set&lt;&gt;</a></code>
          that accepts weighted samples, you must specify the type of the weight
          parameter as the 3rd template parameter, as follows:
        </p>
<pre class="programlisting"><span class="comment">// 3rd template parameter 'int' means this is a weighted</span>
<span class="comment">// accumulator set where the weights have type 'int'</span>
<span class="identifier">accumulator_set</span><span class="special">&lt;</span> <span class="keyword">int</span><span class="special">,</span> <span class="identifier">features</span><span class="special">&lt;</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">sum</span> <span class="special">&gt;,</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="identifier">acc</span><span class="special">;</span>
</pre>
<p>
          When you specify a weight, all the accumulators in the set are replaced
          with their weighted equivalents. For example, the above <code class="computeroutput"><a class="link" href="../boost/accumulators/accumulator_set.html" title="Struct template accumulator_set">accumulator_set&lt;&gt;</a></code>
          declaration is equivalent to the following:
        </p>
<pre class="programlisting"><span class="comment">// Since we specified a weight, tag::sum becomes tag::weighted_sum</span>
<span class="identifier">accumulator_set</span><span class="special">&lt;</span> <span class="keyword">int</span><span class="special">,</span> <span class="identifier">features</span><span class="special">&lt;</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_sum</span> <span class="special">&gt;,</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="identifier">acc</span><span class="special">;</span>
</pre>
<p>
          When passing samples to the accumulator set, you must also specify the
          weight of each sample. You can do that with the <code class="computeroutput"><span class="identifier">weight</span></code>
          named parameter, as follows:
        </p>
<pre class="programlisting"><span class="identifier">acc</span><span class="special">(</span><span class="number">1</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">2</span><span class="special">);</span> <span class="comment">//   1 * 2</span>
<span class="identifier">acc</span><span class="special">(</span><span class="number">2</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">4</span><span class="special">);</span> <span class="comment">//   2 * 4</span>
<span class="identifier">acc</span><span class="special">(</span><span class="number">3</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">6</span><span class="special">);</span> <span class="comment">// + 3 * 6</span>
                    <span class="comment">// -------</span>
                    <span class="comment">// =    28</span>
</pre>
<p>
          You can then extract the result with the <code class="computeroutput"><span class="identifier">sum</span><span class="special">()</span></code> extractor, as follows:
        </p>
<pre class="programlisting"><span class="comment">// This prints "28"</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">sum</span><span class="special">(</span><span class="identifier">acc</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
</pre>
<div class="note"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../doc/src/images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>
            When working with weighted statistical accumulators from the Statistical
            Accumulators Library, be sure to include the appropriate header. For
            instance, <code class="computeroutput"><span class="identifier">weighted_sum</span></code>
            is defined in <code class="computeroutput"><span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">accumulators</span><span class="special">/</span><span class="identifier">statistics</span><span class="special">/</span><span class="identifier">weighted_sum</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span></code>.
          </p></td></tr>
</table></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="accumulators.user_s_guide.the_accumulators_framework.numeric_operators_sub_library"></a><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_accumulators_framework.numeric_operators_sub_library" title="Numeric Operators Sub-Library">Numeric
        Operators Sub-Library</a>
</h4></div></div></div>
<p>
          This section describes the function objects in the <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">numeric</span></code>
          namespace, which is a sub-library that provides function objects and meta-functions
          corresponding to the infix operators in C++.
        </p>
<p>
          In the <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">numeric</span><span class="special">::</span><span class="identifier">operators</span></code> namespace are additional operator
          overloads for some useful operations not provided by the standard library,
          such as multiplication of a <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">complex</span><span class="special">&lt;&gt;</span></code> with a scalar.
        </p>
<p>
          In the <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span></code> namespace are function object
          equivalents of the infix operators. These function object types are heterogeneous,
          and so are more general than the standard ones found in the <code class="literal">&lt;functional&gt;</code>
          header. They use the Boost.Typeof library to deduce the return types of
          the infix expressions they evaluate. In addition, they look within the
          <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">numeric</span><span class="special">::</span><span class="identifier">operators</span></code> namespace to consider any additional
          overloads that might be defined there.
        </p>
<p>
          In the <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">numeric</span></code> namespace are global polymorphic
          function objects corresponding to the function object types defined in
          the <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span></code> namespace. For example, <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">numeric</span><span class="special">::</span><span class="identifier">plus</span><span class="special">(</span><span class="identifier">a</span><span class="special">,</span> <span class="identifier">b</span><span class="special">)</span></code> is equivalent to <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">plus</span><span class="special">&lt;</span><span class="identifier">A</span><span class="special">,</span> <span class="identifier">B</span><span class="special">&gt;()(</span><span class="identifier">a</span><span class="special">,</span> <span class="identifier">b</span><span class="special">)</span></code>, and both are equivalent to <code class="computeroutput"><span class="keyword">using</span> <span class="keyword">namespace</span>
          <span class="identifier">boost</span><span class="special">::</span><span class="identifier">numeric</span><span class="special">::</span><span class="identifier">operators</span><span class="special">;</span>
          <span class="identifier">a</span> <span class="special">+</span>
          <span class="identifier">b</span><span class="special">;</span></code>.
        </p>
<p>
          The Numeric Operators Sub-Library also gives several ways to sub-class
          and a way to sub-class and specialize operations. One way uses tag dispatching
          on the types of the operands. The other way is based on the compile-time
          properties of the operands.
        </p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="accumulators.user_s_guide.the_accumulators_framework.extending_the_accumulators_framework"></a><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_accumulators_framework.extending_the_accumulators_framework" title="Extending the Accumulators Framework">Extending
        the Accumulators Framework</a>
</h4></div></div></div>
<div class="toc"><dl class="toc">
<dt><span class="section"><a href="user_s_guide.html#accumulators.user_s_guide.the_accumulators_framework.extending_the_accumulators_framework.defining_a_new_accumulator">Defining
          a New Accumulator</a></span></dt>
<dt><span class="section"><a href="user_s_guide.html#accumulators.user_s_guide.the_accumulators_framework.extending_the_accumulators_framework.defining_a_new_feature">Defining
          a New Feature</a></span></dt>
<dt><span class="section"><a href="user_s_guide.html#accumulators.user_s_guide.the_accumulators_framework.extending_the_accumulators_framework.defining_a_new_extractor">Defining
          a New Extractor</a></span></dt>
<dt><span class="section"><a href="user_s_guide.html#accumulators.user_s_guide.the_accumulators_framework.extending_the_accumulators_framework.controlling_dependencies">Controlling
          Dependencies</a></span></dt>
<dt><span class="section"><a href="user_s_guide.html#accumulators.user_s_guide.the_accumulators_framework.extending_the_accumulators_framework.operators_ex">Specializing
          Numeric Operators</a></span></dt>
</dl></div>
<p>
          This section describes how to extend the Accumulators Framework by defining
          new accumulators, features and extractors. Also covered are how to control
          the dependency resolution of features within an accumulator set.
        </p>
<div class="section">
<div class="titlepage"><div><div><h5 class="title">
<a name="accumulators.user_s_guide.the_accumulators_framework.extending_the_accumulators_framework.defining_a_new_accumulator"></a><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_accumulators_framework.extending_the_accumulators_framework.defining_a_new_accumulator" title="Defining a New Accumulator">Defining
          a New Accumulator</a>
</h5></div></div></div>
<p>
            All new accumulators must satisfy the <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_accumulators_framework.concepts.accumulator_concept">Accumulator
            Concept</a>. Below is a sample class that satisfies the accumulator
            concept, which simply sums the values of all samples passed into it.
          </p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">accumulators</span><span class="special">/</span><span class="identifier">framework</span><span class="special">/</span><span class="identifier">accumulator_base</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">accumulators</span><span class="special">/</span><span class="identifier">framework</span><span class="special">/</span><span class="identifier">parameters</span><span class="special">/</span><span class="identifier">sample</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>

<span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span>                           <span class="comment">// Putting your accumulators in the</span>
<span class="keyword">namespace</span> <span class="identifier">accumulators</span> <span class="special">{</span>                    <span class="comment">// impl namespace has some</span>
<span class="keyword">namespace</span> <span class="identifier">impl</span> <span class="special">{</span>                            <span class="comment">// advantages. See below.</span>

<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Sample</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <span class="identifier">sum_accumulator</span>                      <span class="comment">// All accumulators should inherit from</span>
  <span class="special">:</span> <span class="identifier">accumulator_base</span>                        <span class="comment">// accumulator_base.</span>
<span class="special">{</span>
    <span class="keyword">typedef</span> <span class="identifier">Sample</span> <span class="identifier">result_type</span><span class="special">;</span>             <span class="comment">// The type returned by result() below.</span>

    <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Args</span><span class="special">&gt;</span>                 <span class="comment">// The constructor takes an argument pack.</span>
    <span class="identifier">sum_accumulator</span><span class="special">(</span><span class="identifier">Args</span> <span class="keyword">const</span> <span class="special">&amp;</span> <span class="identifier">args</span><span class="special">)</span>
      <span class="special">:</span> <span class="identifier">sum</span><span class="special">(</span><span class="identifier">args</span><span class="special">[</span><span class="identifier">sample</span> <span class="special">|</span> <span class="identifier">Sample</span><span class="special">()])</span>        <span class="comment">// Maybe there is an initial value in the</span>
    <span class="special">{</span>                                       <span class="comment">// argument pack. ('sample' is defined in</span>
    <span class="special">}</span>                                       <span class="comment">// sample.hpp, included above.)</span>

    <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Args</span><span class="special">&gt;</span>                 <span class="comment">// The accumulate function is the function</span>
    <span class="keyword">void</span> <span class="keyword">operator</span> <span class="special">()(</span><span class="identifier">Args</span> <span class="keyword">const</span> <span class="special">&amp;</span> <span class="identifier">args</span><span class="special">)</span>     <span class="comment">// call operator, and it also accepts an</span>
    <span class="special">{</span>                                       <span class="comment">// argument pack.</span>
        <span class="keyword">this</span><span class="special">-&gt;</span><span class="identifier">sum</span> <span class="special">+=</span> <span class="identifier">args</span><span class="special">[</span><span class="identifier">sample</span><span class="special">];</span>
    <span class="special">}</span>

    <span class="identifier">result_type</span> <span class="identifier">result</span><span class="special">(</span><span class="identifier">dont_care</span><span class="special">)</span> <span class="keyword">const</span>     <span class="comment">// The result function will also be passed</span>
    <span class="special">{</span>                                       <span class="comment">// an argument pack, but we don't use it here,</span>
        <span class="keyword">return</span> <span class="keyword">this</span><span class="special">-&gt;</span><span class="identifier">sum</span><span class="special">;</span>                   <span class="comment">// so we use "dont_care" as the argument type.</span>
    <span class="special">}</span>
<span class="keyword">private</span><span class="special">:</span>
    <span class="identifier">Sample</span> <span class="identifier">sum</span><span class="special">;</span>
<span class="special">};</span>

<span class="special">}}}</span>
</pre>
<p>
            Much of the above should be pretty self-explanatory, except for the use
            of argument packs which may be confusing if you have never used the
            <a href="../../../libs/parameter/index.html" target="_top">Boost.Parameter</a>
            library before. An argument pack is a cluster of values, each of which
            can be accessed with a key. So <code class="computeroutput"><span class="identifier">args</span><span class="special">[</span><span class="identifier">sample</span><span class="special">]</span></code> extracts from the pack the value associated
            with the <code class="computeroutput"><span class="identifier">sample</span></code> key.
            And the cryptic <code class="computeroutput"><span class="identifier">args</span><span class="special">[</span><span class="identifier">sample</span> <span class="special">|</span> <span class="identifier">Sample</span><span class="special">()]</span></code> evaluates to the value associated
            with the <code class="computeroutput"><span class="identifier">sample</span></code> key if
            it exists, or a default-constructed <code class="computeroutput"><span class="identifier">Sample</span></code>
            if it doesn't.
          </p>
<p>
            The example above demonstrates the most common attributes of an accumulator.
            There are other optional member functions that have special meaning.
            In particular:
          </p>
<div class="variablelist">
<p class="title"><b>Optional Accumulator Member Functions</b></p>
<dl class="variablelist">
<dt><span class="term"><code class="literal">on_drop(Args)</code></span></dt>
<dd><p>
                  Defines an action to be taken when this accumulator is dropped.
                  See the section on <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_accumulators_framework.extending_the_accumulators_framework.defining_a_new_accumulator.droppable_accumulators">Droppable
                  Accumulators</a>.
                </p></dd>
</dl>
</div>
<h4>
<a name="accumulators.user_s_guide.the_accumulators_framework.extending_the_accumulators_framework.defining_a_new_accumulator.h0"></a>
            <span class="phrase"><a name="accumulators.user_s_guide.the_accumulators_framework.extending_the_accumulators_framework.defining_a_new_accumulator.accessing_other_accumulators_in_the_set"></a></span><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_accumulators_framework.extending_the_accumulators_framework.defining_a_new_accumulator.accessing_other_accumulators_in_the_set">Accessing
            Other Accumulators in the Set</a>
          </h4>
<p>
            Some accumulators depend on other accumulators within the same accumulator
            set. In those cases, it is necessary to be able to access those other
            accumulators. To make this possible, the <code class="computeroutput"><a class="link" href="../boost/accumulators/accumulator_set.html" title="Struct template accumulator_set">accumulator_set&lt;&gt;</a></code>
            passes a reference to itself when invoking the member functions of its
            contained accumulators. It can be accessed by using the special <code class="computeroutput"><span class="identifier">accumulator</span></code> key with the argument pack.
            Consider how we might implement <code class="computeroutput"><span class="identifier">mean_accumulator</span></code>:
          </p>
<pre class="programlisting"><span class="comment">// Mean == (Sum / Count)</span>
<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Sample</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <span class="identifier">mean_accumulator</span> <span class="special">:</span> <span class="identifier">accumulator_base</span>
<span class="special">{</span>
    <span class="keyword">typedef</span> <span class="identifier">Sample</span> <span class="identifier">result_type</span><span class="special">;</span>
    <span class="identifier">mean_accumulator</span><span class="special">(</span><span class="identifier">dont_care</span><span class="special">)</span> <span class="special">{}</span>

    <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Args</span><span class="special">&gt;</span>
    <span class="identifier">result_type</span> <span class="identifier">result</span><span class="special">(</span><span class="identifier">Args</span> <span class="keyword">const</span> <span class="special">&amp;</span><span class="identifier">args</span><span class="special">)</span> <span class="keyword">const</span>
    <span class="special">{</span>
        <span class="keyword">return</span> <span class="identifier">sum</span><span class="special">(</span><span class="identifier">args</span><span class="special">[</span><span class="identifier">accumulator</span><span class="special">])</span> <span class="special">/</span> <span class="identifier">count</span><span class="special">(</span><span class="identifier">args</span><span class="special">[</span><span class="identifier">accumulator</span><span class="special">]);</span>
    <span class="special">}</span>
<span class="special">};</span>
</pre>
<p>
            <code class="computeroutput"><span class="identifier">mean</span></code> depends on the
            <code class="computeroutput"><span class="identifier">sum</span></code> and <code class="computeroutput"><span class="identifier">count</span></code> accumulators. (We'll see in the
            next section how to specify these dependencies.) The result of the mean
            accumulator is merely the result of the sum accumulator divided by the
            result of the count accumulator. Consider how we write that: <code class="computeroutput"><span class="identifier">sum</span><span class="special">(</span><span class="identifier">args</span><span class="special">[</span><span class="identifier">accumulator</span><span class="special">])</span>
            <span class="special">/</span> <span class="identifier">count</span><span class="special">(</span><span class="identifier">args</span><span class="special">[</span><span class="identifier">accumulator</span><span class="special">])</span></code>. The expression <code class="computeroutput"><span class="identifier">args</span><span class="special">[</span><span class="identifier">accumulator</span><span class="special">]</span></code> evaluates to a reference to the <code class="computeroutput"><a class="link" href="../boost/accumulators/accumulator_set.html" title="Struct template accumulator_set">accumulator_set&lt;&gt;</a></code> that contains this
            <code class="computeroutput"><span class="identifier">mean_accumulator</span></code>. It
            also contains the <code class="computeroutput"><span class="identifier">sum</span></code>
            and <code class="computeroutput"><span class="identifier">count</span></code> accumulators,
            and we can access their results with the extractors defined for those
            features: <code class="computeroutput"><span class="identifier">sum</span></code> and <code class="computeroutput"><span class="identifier">count</span></code>.
          </p>
<div class="note"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../doc/src/images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>
              Accumulators that inherit from <code class="computeroutput"><a class="link" href="../boost/accumulators/accumulator_base.html" title="Struct accumulator_base">accumulator_base</a></code> get
              an empty <code class="computeroutput"><span class="keyword">operator</span> <span class="special">()</span></code>,
              so accumulators like <code class="computeroutput"><span class="identifier">mean_accumulator</span></code>
              above need not define one.
            </p></td></tr>
</table></div>
<p>
            All the member functions that accept an argument pack have access to
            the enclosing <code class="computeroutput"><a class="link" href="../boost/accumulators/accumulator_set.html" title="Struct template accumulator_set">accumulator_set&lt;&gt;</a></code>
            via the <code class="computeroutput"><span class="identifier">accumulator</span></code> key,
            including the constructor. The accumulators within the set are constructed
            in an order determined by their interdependencies. As a result, it is
            safe for an accumulator to access one on which it depends during construction.
          </p>
<h4>
<a name="accumulators.user_s_guide.the_accumulators_framework.extending_the_accumulators_framework.defining_a_new_accumulator.h1"></a>
            <span class="phrase"><a name="accumulators.user_s_guide.the_accumulators_framework.extending_the_accumulators_framework.defining_a_new_accumulator.infix_notation_and_the_numeric_operators_sub_library"></a></span><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_accumulators_framework.extending_the_accumulators_framework.defining_a_new_accumulator.infix_notation_and_the_numeric_operators_sub_library">Infix
            Notation and the Numeric Operators Sub-Library</a>
          </h4>
<p>
            Although not necessary, it can be a good idea to put your accumulator
            implementations in the <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">accumulators</span><span class="special">::</span><span class="identifier">impl</span></code>
            namespace. This namespace pulls in any operators defined in the <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">numeric</span><span class="special">::</span><span class="identifier">operators</span></code> namespace with a using directive.
            The Numeric Operators Sub-Library defines some additional overloads that
            will make your accumulators work with all sorts of data types.
          </p>
<p>
            Consider <code class="computeroutput"><span class="identifier">mean_accumulator</span></code>
            defined above. It divides the sum of the samples by the count. The type
            of the count is <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span></code>. What if the sample type doesn't
            define division by <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span></code>?
            That's the case for <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">complex</span><span class="special">&lt;&gt;</span></code>. You might think that if the
            sample type is <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">complex</span><span class="special">&lt;&gt;</span></code>,
            the code would not work, but in fact it does. That's because Numeric
            Operators Sub-Library defines an overloaded <code class="computeroutput"><span class="keyword">operator</span><span class="special">/</span></code> for <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">complex</span><span class="special">&lt;&gt;</span></code> and <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span></code>.
            This operator is defined in the <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">numeric</span><span class="special">::</span><span class="identifier">operators</span></code>
            namespace and will be found within the <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">accumulators</span><span class="special">::</span><span class="identifier">impl</span></code>
            namespace. That's why it's a good idea to put your accumulators there.
          </p>
<h4>
<a name="accumulators.user_s_guide.the_accumulators_framework.extending_the_accumulators_framework.defining_a_new_accumulator.h2"></a>
            <span class="phrase"><a name="accumulators.user_s_guide.the_accumulators_framework.extending_the_accumulators_framework.defining_a_new_accumulator.droppable_accumulators"></a></span><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_accumulators_framework.extending_the_accumulators_framework.defining_a_new_accumulator.droppable_accumulators">Droppable
            Accumulators</a>
          </h4>
<p>
            The term "droppable" refers to an accumulator that can be removed
            from the <code class="computeroutput"><a class="link" href="../boost/accumulators/accumulator_set.html" title="Struct template accumulator_set">accumulator_set&lt;&gt;</a></code>.
            You can request that an accumulator be made droppable by using the <code class="computeroutput">droppable&lt;&gt;</code> class template.
          </p>
<pre class="programlisting"><span class="comment">// calculate sum and count, make sum droppable:</span>
<span class="identifier">accumulator_set</span><span class="special">&lt;</span> <span class="keyword">double</span><span class="special">,</span> <span class="identifier">features</span><span class="special">&lt;</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">count</span><span class="special">,</span> <span class="identifier">droppable</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">sum</span><span class="special">&gt;</span> <span class="special">&gt;</span> <span class="special">&gt;</span> <span class="identifier">acc</span><span class="special">;</span>

<span class="comment">// add some data</span>
<span class="identifier">acc</span><span class="special">(</span><span class="number">3.0</span><span class="special">);</span>
<span class="identifier">acc</span><span class="special">(</span><span class="number">2.0</span><span class="special">);</span>

<span class="comment">// drop the sum (sum is 5 here)</span>
<span class="identifier">acc</span><span class="special">.</span><span class="identifier">drop</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">sum</span><span class="special">&gt;();</span>

<span class="comment">// add more data</span>
<span class="identifier">acc</span><span class="special">(</span><span class="number">1.0</span><span class="special">);</span>

<span class="comment">// This will display "3" and "5"</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">count</span><span class="special">(</span><span class="identifier">acc</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="char">' '</span> <span class="special">&lt;&lt;</span> <span class="identifier">sum</span><span class="special">(</span><span class="identifier">acc</span><span class="special">);</span>
</pre>
<p>
            Any accumulators that get added to an accumulator set in order to satisfy
            dependencies on droppable accumulators are themselves droppable. Consider
            the following accumulator:
          </p>
<pre class="programlisting"><span class="comment">// Sum is not droppable. Mean is droppable. Count, brought in to </span>
<span class="comment">// satisfy mean's dependencies, is implicitly droppable, too.</span>
<span class="identifier">accumulator_set</span><span class="special">&lt;</span> <span class="keyword">double</span><span class="special">,</span> <span class="identifier">features</span><span class="special">&lt;</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">sum</span><span class="special">,</span> <span class="identifier">droppable</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">mean</span><span class="special">&gt;</span> <span class="special">&gt;</span> <span class="special">&gt;</span> <span class="identifier">acc</span><span class="special">;</span>
</pre>
<p>
            <code class="computeroutput"><span class="identifier">mean</span></code> depends on <code class="computeroutput"><span class="identifier">sum</span></code> and <code class="computeroutput"><span class="identifier">count</span></code>.
            Since <code class="computeroutput"><span class="identifier">mean</span></code> is droppable,
            so too is <code class="computeroutput"><span class="identifier">count</span></code>. However,
            we have explicitly requested that <code class="computeroutput"><span class="identifier">sum</span></code>
            be not droppable, so it isn't. Had we left <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">sum</span></code>
            out of the above declaration, the <code class="computeroutput"><span class="identifier">sum</span></code>
            accumulator would have been implicitly droppable.
          </p>
<p>
            A droppable accumulator is reference counted, and is only really dropped
            after all the accumulators that depend on it have been dropped. This
            can lead to some surprising behavior in some situations.
          </p>
<pre class="programlisting"><span class="comment">// calculate sum and mean, make mean droppable. </span>
<span class="identifier">accumulator_set</span><span class="special">&lt;</span> <span class="keyword">double</span><span class="special">,</span> <span class="identifier">features</span><span class="special">&lt;</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">sum</span><span class="special">,</span> <span class="identifier">droppable</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">mean</span><span class="special">&gt;</span> <span class="special">&gt;</span> <span class="special">&gt;</span> <span class="identifier">acc</span><span class="special">;</span>

<span class="comment">// add some data</span>
<span class="identifier">acc</span><span class="special">(</span><span class="number">1.0</span><span class="special">);</span>
<span class="identifier">acc</span><span class="special">(</span><span class="number">2.0</span><span class="special">);</span>

<span class="comment">// drop the mean. mean's reference count</span>
<span class="comment">// drops to 0, so it's really dropped. So</span>
<span class="comment">// too, count's reference count drops to 0</span>
<span class="comment">// and is really dropped.</span>
<span class="identifier">acc</span><span class="special">.</span><span class="identifier">drop</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">mean</span><span class="special">&gt;();</span>

<span class="comment">// add more data. Sum continues to accumulate!</span>
<span class="identifier">acc</span><span class="special">(</span><span class="number">3.0</span><span class="special">);</span>

<span class="comment">// This will display "6 2 3"</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">sum</span><span class="special">(</span><span class="identifier">acc</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="char">' '</span>
          <span class="special">&lt;&lt;</span> <span class="identifier">count</span><span class="special">(</span><span class="identifier">acc</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="char">' '</span>
          <span class="special">&lt;&lt;</span> <span class="identifier">mean</span><span class="special">(</span><span class="identifier">acc</span><span class="special">);</span>
</pre>
<p>
            Note that at the point at which <code class="computeroutput"><span class="identifier">mean</span></code>
            is dropped, <code class="computeroutput"><span class="identifier">sum</span></code> is 3,
            <code class="computeroutput"><span class="identifier">count</span></code> is 2, and therefore
            <code class="computeroutput"><span class="identifier">mean</span></code> is 1.5. But since
            <code class="computeroutput"><span class="identifier">sum</span></code> continues to accumulate
            even after <code class="computeroutput"><span class="identifier">mean</span></code> has been
            dropped, the value of <code class="computeroutput"><span class="identifier">mean</span></code>
            continues to change. If you want to remember the value of <code class="computeroutput"><span class="identifier">mean</span></code> at the point it is dropped, you
            should save its value into a local variable.
          </p>
<p>
            The following rules more precisely specify how droppable and non-droppable
            accumulators behave within an accumulator set.
          </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
                There are two types of accumulators: droppable and non-droppable.
                The default is non-droppable.
              </li>
<li class="listitem">
                For any feature <code class="computeroutput"><span class="identifier">X</span></code>,
                both <code class="computeroutput"><span class="identifier">X</span></code> and <code class="computeroutput"><span class="identifier">droppable</span><span class="special">&lt;</span><span class="identifier">X</span><span class="special">&gt;</span></code>
                satisfy the <code class="computeroutput"><span class="identifier">X</span></code> dependency.
              </li>
<li class="listitem">
                If feature <code class="computeroutput"><span class="identifier">X</span></code> depends
                on <code class="computeroutput"><span class="identifier">Y</span></code> and <code class="computeroutput"><span class="identifier">Z</span></code>, then <code class="computeroutput"><span class="identifier">droppable</span><span class="special">&lt;</span><span class="identifier">X</span><span class="special">&gt;</span></code> depends on <code class="computeroutput"><span class="identifier">droppable</span><span class="special">&lt;</span><span class="identifier">Y</span><span class="special">&gt;</span></code> and <code class="computeroutput"><span class="identifier">droppable</span><span class="special">&lt;</span><span class="identifier">Z</span><span class="special">&gt;</span></code>.
              </li>
<li class="listitem">
                All accumulators have <code class="computeroutput"><span class="identifier">add_ref</span><span class="special">()</span></code> and <code class="computeroutput"><span class="identifier">drop</span><span class="special">()</span></code> member functions.
              </li>
<li class="listitem">
                For non-droppable accumulators, <code class="computeroutput"><span class="identifier">drop</span><span class="special">()</span></code> is a no-op, and <code class="computeroutput"><span class="identifier">add_ref</span><span class="special">()</span></code> invokes <code class="computeroutput"><span class="identifier">add_ref</span><span class="special">()</span></code> on all accumulators corresponding
                to the features upon which the current accumulator depends.
              </li>
<li class="listitem">
                Droppable accumulators have a reference count and define <code class="computeroutput"><span class="identifier">add_ref</span><span class="special">()</span></code>
                and <code class="computeroutput"><span class="identifier">drop</span><span class="special">()</span></code>
                to manipulate the reference count.
              </li>
<li class="listitem">
                For droppable accumulators, <code class="computeroutput"><span class="identifier">add_ref</span><span class="special">()</span></code> increments the accumulator's reference
                count, and also <code class="computeroutput"><span class="identifier">add_ref</span><span class="special">()</span></code>'s the accumulators corresponding
                to the features upon which the current accumulator depends.
              </li>
<li class="listitem">
                For droppable accumulators, <code class="computeroutput"><span class="identifier">drop</span><span class="special">()</span></code> decrements the accumulator's reference
                count, and also <code class="computeroutput"><span class="identifier">drop</span><span class="special">()</span></code>'s the accumulators corresponding
                to the features upon which the current accumulator depends.
              </li>
<li class="listitem">
                The accumulator_set constructor walks the list of <span class="bold"><strong>user-specified</strong></span>
                features and <code class="computeroutput"><span class="identifier">add_ref</span><span class="special">()</span></code>'s the accumulator that corresponds
                to each of them. (Note: that means that an accumulator that is not
                user-specified but in the set merely to satisfy a dependency will
                be dropped as soon as all its dependencies have been dropped. Ones
                that have been user specified are not dropped until their dependencies
                have been dropped <span class="bold"><strong>and</strong></span> the user has
                explicitly dropped the accumulator.)
              </li>
<li class="listitem">
                Droppable accumulators check their reference count in their accumulate
                member function. If the reference count is 0, the function is a no-op.
              </li>
<li class="listitem">
                Users are not allowed to drop a feature that is not user-specified
                and marked as droppable.
              </li>
</ul></div>
<p>
            And as an optimization:
          </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
                If the user specifies the non-droppable feature <code class="computeroutput"><span class="identifier">X</span></code>,
                which depends on <code class="computeroutput"><span class="identifier">Y</span></code>
                and <code class="computeroutput"><span class="identifier">Z</span></code>, then the accumulators
                for <code class="computeroutput"><span class="identifier">Y</span></code> and <code class="computeroutput"><span class="identifier">Z</span></code> can be safely made non-droppable,
                as well as any accumulators on which they depend.
              </li></ul></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h5 class="title">
<a name="accumulators.user_s_guide.the_accumulators_framework.extending_the_accumulators_framework.defining_a_new_feature"></a><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_accumulators_framework.extending_the_accumulators_framework.defining_a_new_feature" title="Defining a New Feature">Defining
          a New Feature</a>
</h5></div></div></div>
<p>
            Once we have implemented an accumulator, we must define a feature for
            it so that users can specify the feature when declaring an <code class="computeroutput"><a class="link" href="../boost/accumulators/accumulator_set.html" title="Struct template accumulator_set">accumulator_set&lt;&gt;</a></code>. We typically put
            the features into a nested namespace, so that later we can define an
            extractor of the same name. All features must satisfy the <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_accumulators_framework.concepts.feature_concept">Feature
            Concept</a>. Using <code class="computeroutput"><a class="link" href="../boost/accumulators/depends_on.html" title="Struct template depends_on">depends_on&lt;&gt;</a></code>
            makes satisfying the concept simple. Below is an example of a feature
            definition.
          </p>
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">accumulators</span> <span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">tag</span> <span class="special">{</span>

<span class="keyword">struct</span> <span class="identifier">mean</span>                         <span class="comment">// Features should inherit from</span>
  <span class="special">:</span> <span class="identifier">depends_on</span><span class="special">&lt;</span> <span class="identifier">count</span><span class="special">,</span> <span class="identifier">sum</span> <span class="special">&gt;</span>        <span class="comment">// depends_on&lt;&gt; to specify dependencies</span>
<span class="special">{</span>
    <span class="comment">// Define a nested typedef called 'impl' that specifies which</span>
    <span class="comment">// accumulator implements this feature. </span>
    <span class="keyword">typedef</span> <span class="identifier">accumulators</span><span class="special">::</span><span class="identifier">impl</span><span class="special">::</span><span class="identifier">mean_accumulator</span><span class="special">&lt;</span> <span class="identifier">mpl</span><span class="special">::</span><span class="identifier">_1</span> <span class="special">&gt;</span> <span class="identifier">impl</span><span class="special">;</span>
<span class="special">};</span>

<span class="special">}}}</span>
</pre>
<p>
            The only two things we must do to define the <code class="computeroutput"><span class="identifier">mean</span></code>
            feature is to specify the dependencies with <code class="computeroutput"><a class="link" href="../boost/accumulators/depends_on.html" title="Struct template depends_on">depends_on&lt;&gt;</a></code>
            and define the nested <code class="computeroutput"><span class="identifier">impl</span></code>
            typedef. Even features that have no dependencies should inherit from
            <code class="computeroutput"><a class="link" href="../boost/accumulators/depends_on.html" title="Struct template depends_on">depends_on&lt;&gt;</a></code>. The nested <code class="computeroutput"><span class="identifier">impl</span></code> type must be an <a href="../../../libs/mpl/doc/refmanual/lambda-expression.html" target="_top">MPL
            Lambda Expression</a>. The result of <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">apply</span><span class="special">&lt;</span> <span class="identifier">impl</span><span class="special">,</span> <em class="replaceable"><code>sample-type</code></em><span class="special">,</span> <em class="replaceable"><code>weight-type</code></em> <span class="special">&gt;::</span><span class="identifier">type</span></code> must be be the type of the accumulator
            that implements this feature. The use of <a href="../../../libs/mpl/index.html" target="_top">MPL</a>
            placeholders like <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">_1</span></code>
            make it especially easy to make a template such as <code class="computeroutput"><span class="identifier">mean_accumulator</span><span class="special">&lt;&gt;</span></code> an <a href="../../../libs/mpl/doc/refmanual/lambda-expression.html" target="_top">MPL
            Lambda Expression</a>. Here, <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">_1</span></code>
            will be replaced with the sample type. Had we used <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">_2</span></code>,
            it would have been replaced with the weight type.
          </p>
<p>
            What about accumulator types that are not templates? If you have a <code class="computeroutput"><span class="identifier">foo_accumulator</span></code> which is a plain struct
            and not a template, you could turn it into an <a href="../../../libs/mpl/doc/refmanual/lambda-expression.html" target="_top">MPL
            Lambda Expression</a> using <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">always</span><span class="special">&lt;&gt;</span></code>, like this:
          </p>
<pre class="programlisting"><span class="comment">// An MPL lambda expression that always evaluates to</span>
<span class="comment">// foo_accumulator:</span>
<span class="keyword">typedef</span> <span class="identifier">mpl</span><span class="special">::</span><span class="identifier">always</span><span class="special">&lt;</span> <span class="identifier">foo_accumulator</span> <span class="special">&gt;</span> <span class="identifier">impl</span><span class="special">;</span>
</pre>
<p>
            If you are ever unsure, or if you are not comfortable with MPL lambda
            expressions, you could always define <code class="computeroutput"><span class="identifier">impl</span></code>
            explicitly:
          </p>
<pre class="programlisting"><span class="comment">// Same as 'typedef mpl::always&lt; foo_accumulator &gt; impl;'</span>
<span class="keyword">struct</span> <span class="identifier">impl</span>
<span class="special">{</span>
    <span class="keyword">template</span><span class="special">&lt;</span> <span class="keyword">typename</span> <span class="identifier">Sample</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">Weight</span> <span class="special">&gt;</span>
    <span class="keyword">struct</span> <span class="identifier">apply</span>
    <span class="special">{</span>
        <span class="keyword">typedef</span> <span class="identifier">foo_accumulator</span> <span class="identifier">type</span><span class="special">;</span>
    <span class="special">};</span>
<span class="special">};</span>
</pre>
<p>
            Here, <code class="computeroutput"><span class="identifier">impl</span></code> is a binary
            <a href="../../../libs/mpl/doc/refmanual/metafunction-class.html" target="_top">MPL
            Metafunction Class</a>, which is a kind of <a href="../../../libs/mpl/doc/refmanual/lambda-expression.html" target="_top">MPL
            Lambda Expression</a>. The nested <code class="computeroutput"><span class="identifier">apply</span><span class="special">&lt;&gt;</span></code> template is part of the metafunction
            class protocol and tells MPL how to build the accumulator type given
            the sample and weight types.
          </p>
<p>
            All features must also provide a nested <code class="computeroutput"><span class="identifier">is_weight_accumulator</span></code>
            typedef. It must be either <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">true_</span></code>
            or <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">false_</span></code>. <code class="computeroutput"><a class="link" href="../boost/accumulators/depends_on.html" title="Struct template depends_on">depends_on&lt;&gt;</a></code>
            provides a default of <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">false_</span></code>
            for all features that inherit from it, but that can be overridden (or
            hidden, technically speaking) in the derived type. When the feature represents
            an accumulation of information about the weights instead of the samples,
            we can mark this feature as such with <code class="computeroutput"><span class="keyword">typedef</span>
            <span class="identifier">mpl</span><span class="special">::</span><span class="identifier">true_</span> <span class="identifier">is_weight_accumulator</span><span class="special">;</span></code>. The weight accumulators are made external
            if the weight type is specified using the <code class="computeroutput">external&lt;&gt;</code>
            template.
          </p>
</div>
<div class="section">
<div class="titlepage"><div><div><h5 class="title">
<a name="accumulators.user_s_guide.the_accumulators_framework.extending_the_accumulators_framework.defining_a_new_extractor"></a><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_accumulators_framework.extending_the_accumulators_framework.defining_a_new_extractor" title="Defining a New Extractor">Defining
          a New Extractor</a>
</h5></div></div></div>
<p>
            Now that we have an accumulator and a feature, the only thing lacking
            is a way to get results from the accumulator set. The Accumulators Framework
            provides the <code class="computeroutput">extractor&lt;&gt;</code>
            class template to make it simple to define an extractor for your feature.
            Here's an extractor for the <code class="computeroutput"><span class="identifier">mean</span></code>
            feature we defined above:
          </p>
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span>
<span class="keyword">namespace</span> <span class="identifier">accumulators</span> <span class="special">{</span>                <span class="comment">// By convention, we put extractors</span>
<span class="keyword">namespace</span> <span class="identifier">extract</span> <span class="special">{</span>                     <span class="comment">// in the 'extract' namespace</span>

<span class="identifier">extractor</span><span class="special">&lt;</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">mean</span> <span class="special">&gt;</span> <span class="keyword">const</span> <span class="identifier">mean</span> <span class="special">=</span> <span class="special">{};</span> <span class="comment">// Simply define our extractor with</span>
                                        <span class="comment">// our feature tag, like this.</span>
<span class="special">}</span>
<span class="keyword">using</span> <span class="identifier">extract</span><span class="special">::</span><span class="identifier">mean</span><span class="special">;</span>                    <span class="comment">// Pull the extractor into the</span>
                                        <span class="comment">// enclosing namespace.</span>
<span class="special">}}</span>
</pre>
<p>
            Once defined, the <code class="computeroutput"><span class="identifier">mean</span></code>
            extractor can be used to extract the result of the <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">mean</span></code>
            feature from an <code class="computeroutput"><a class="link" href="../boost/accumulators/accumulator_set.html" title="Struct template accumulator_set">accumulator_set&lt;&gt;</a></code>.
          </p>
<p>
            Parameterized features complicate this simple picture. Consider the
            <code class="computeroutput"><span class="identifier">moment</span></code> feature, for calculating
            the <code class="literal"><span class="emphasis"><em>N</em></span></code>-th moment, where <code class="literal"><span class="emphasis"><em>N</em></span></code>
            is specified as a template parameter:
          </p>
<pre class="programlisting"><span class="comment">// An accumulator set for calculating the N-th moment, for N == 2 ...</span>
<span class="identifier">accumulator_set</span><span class="special">&lt;</span> <span class="keyword">double</span><span class="special">,</span> <span class="identifier">features</span><span class="special">&lt;</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">moment</span><span class="special">&lt;</span><span class="number">2</span><span class="special">&gt;</span> <span class="special">&gt;</span> <span class="special">&gt;</span> <span class="identifier">acc</span><span class="special">;</span>

<span class="comment">// ... add some data ...</span>

<span class="comment">// Display the 2nd moment ...</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"2nd moment is "</span> <span class="special">&lt;&lt;</span> <span class="identifier">accumulators</span><span class="special">::</span><span class="identifier">moment</span><span class="special">&lt;</span><span class="number">2</span><span class="special">&gt;(</span><span class="identifier">acc</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
</pre>
<p>
            In the expression <code class="computeroutput"><span class="identifier">accumulators</span><span class="special">::</span><span class="identifier">moment</span><span class="special">&lt;</span><span class="number">2</span><span class="special">&gt;(</span><span class="identifier">acc</span><span class="special">)</span></code>,
            what is <code class="computeroutput"><span class="identifier">moment</span></code>? It cannot
            be an object -- the syntax of C++ will not allow it. Clearly, if we want
            to provide this syntax, we must make <code class="computeroutput"><span class="identifier">moment</span></code>
            a function template. Here's what the definition of the <code class="computeroutput"><span class="identifier">moment</span></code> extractor looks like:
          </p>
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span>
<span class="keyword">namespace</span> <span class="identifier">accumulators</span> <span class="special">{</span>                <span class="comment">// By convention, we put extractors</span>
<span class="keyword">namespace</span> <span class="identifier">extract</span> <span class="special">{</span>                     <span class="comment">// in the 'extract' namespace</span>

<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">int</span> <span class="identifier">N</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">AccumulatorSet</span><span class="special">&gt;</span>
<span class="keyword">typename</span> <span class="identifier">mpl</span><span class="special">::</span><span class="identifier">apply</span><span class="special">&lt;</span><span class="identifier">AccumulatorSet</span><span class="special">,</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">moment</span><span class="special">&lt;</span><span class="identifier">N</span><span class="special">&gt;</span> <span class="special">&gt;::</span><span class="identifier">type</span><span class="special">::</span><span class="identifier">result_type</span>
<span class="identifier">moment</span><span class="special">(</span><span class="identifier">AccumulatorSet</span> <span class="keyword">const</span> <span class="special">&amp;</span><span class="identifier">acc</span><span class="special">)</span>
<span class="special">{</span>
    <span class="keyword">return</span> <span class="identifier">extract_result</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">moment</span><span class="special">&lt;</span><span class="identifier">N</span><span class="special">&gt;</span> <span class="special">&gt;(</span><span class="identifier">acc</span><span class="special">);</span>
<span class="special">}</span>

<span class="special">}</span>
<span class="keyword">using</span> <span class="identifier">extract</span><span class="special">::</span><span class="identifier">moment</span><span class="special">;</span>                  <span class="comment">// Pull the extractor into the</span>
                                        <span class="comment">// enclosing namespace.</span>
<span class="special">}}</span>
</pre>
<p>
            The return type deserves some explanation. Every <code class="computeroutput"><a class="link" href="../boost/accumulators/accumulator_set.html" title="Struct template accumulator_set">accumulator_set&lt;&gt;</a></code>
            type is actually a unary <a href="../../../libs/mpl/doc/refmanual/metafunction-class.html" target="_top">MPL
            Metafunction Class</a>. When you <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">apply</span><span class="special">&lt;&gt;</span></code> an <code class="computeroutput"><a class="link" href="../boost/accumulators/accumulator_set.html" title="Struct template accumulator_set">accumulator_set&lt;&gt;</a></code>
            and a feature, the result is the type of the accumulator within the set
            that implements that feature. And every accumulator provides a nested
            <code class="computeroutput"><span class="identifier">result_type</span></code> typedef that
            tells what its return type is. The extractor simply delegates its work
            to the <code class="computeroutput"><a class="link" href="reference.html#boost.accumulators.extract_result">extract_result()</a></code>
            function.
          </p>
</div>
<div class="section">
<div class="titlepage"><div><div><h5 class="title">
<a name="accumulators.user_s_guide.the_accumulators_framework.extending_the_accumulators_framework.controlling_dependencies"></a><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_accumulators_framework.extending_the_accumulators_framework.controlling_dependencies" title="Controlling Dependencies">Controlling
          Dependencies</a>
</h5></div></div></div>
<p>
            The feature-based dependency resolution of the Accumulators Framework
            is designed to allow multiple different implementation strategies for
            each feature. For instance, two different accumulators may calculate
            the same quantity with different rounding modes, or using different algorithms
            with different size/speed tradeoffs. Other accumulators that depend on
            that quantity shouldn't care how it's calculated. The Accumulators Framework
            handles this by allowing several different accumulators satisfy the same
            feature.
          </p>
<p>
            <span class="bold"><strong>Aliasing feature dependencies with <code class="literal">feature_of&lt;&gt;</code></strong></span>
          </p>
<p>
            Imagine that you would like to implement the hypothetical <span class="emphasis"><em>fubar</em></span>
            statistic, and that you know two ways to calculate fubar on a bunch of
            samples: an accurate but slow calculation and an approximate but fast
            calculation. You might opt to make the accurate calculation the default,
            so you implement two accumulators and call them <code class="computeroutput"><span class="identifier">impl</span><span class="special">::</span><span class="identifier">fubar_impl</span></code>
            and <code class="computeroutput"><span class="identifier">impl</span><span class="special">::</span><span class="identifier">fast_fubar_impl</span></code>. You would also define
            the <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">fubar</span></code> and <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">fast_fubar</span></code>
            features as described <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_accumulators_framework.extending_the_accumulators_framework.defining_a_new_feature" title="Defining a New Feature">above</a>.
            Now, you would like to inform the Accumulators Framework that these two
            features are the same from the point of view of dependency resolution.
            You can do that with <code class="computeroutput"><a class="link" href="../boost/accumulators/feature_of.html" title="Struct template feature_of">feature_of&lt;&gt;</a></code>,
            as follows:
          </p>
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">accumulators</span>
<span class="special">{</span>
    <span class="comment">// For the purposes of feature-based dependency resolution,</span>
    <span class="comment">// fast_fubar provides the same feature as fubar</span>
    <span class="keyword">template</span><span class="special">&lt;&gt;</span>
    <span class="keyword">struct</span> <span class="identifier">feature_of</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">fast_fubar</span><span class="special">&gt;</span>
      <span class="special">:</span> <span class="identifier">feature_of</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">fubar</span><span class="special">&gt;</span>
    <span class="special">{</span>
    <span class="special">};</span>
<span class="special">}}</span>
</pre>
<p>
            The above code instructs the Accumulators Framework that, if another
            accumulator in the set depends on the <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">fubar</span></code>
            feature, the <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">fast_fubar</span></code> feature is an acceptable
            substitute.
          </p>
<p>
            <span class="bold"><strong>Registering feature variants with <code class="literal">as_feature&lt;&gt;</code></strong></span>
          </p>
<p>
            You may have noticed that some feature variants in the Accumulators Framework
            can be specified with a nicer syntax. For instance, instead of <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">mean</span></code> and <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">immediate_mean</span></code>
            you can specify them with <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">mean</span><span class="special">(</span><span class="identifier">lazy</span><span class="special">)</span></code> and <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">mean</span><span class="special">(</span><span class="identifier">immediate</span><span class="special">)</span></code> respectively. These are merely aliases,
            but the syntax makes the relationship between the two clearer. You can
            create these feature aliases with the <code class="computeroutput"><a class="link" href="../boost/accumulators/as_feature.html" title="Struct template as_feature">as_feature&lt;&gt;</a></code>
            trait. Given the fubar example above, you might decide to alias <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">fubar</span><span class="special">(</span><span class="identifier">accurate</span><span class="special">)</span></code>
            with <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">fubar</span></code> and <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">fubar</span><span class="special">(</span><span class="identifier">fast</span><span class="special">)</span></code> with <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">fast_fubar</span></code>.
            You would do that as follows:
          </p>
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">accumulators</span>
<span class="special">{</span>
    <span class="keyword">struct</span> <span class="identifier">fast</span> <span class="special">{};</span>     <span class="comment">// OK to leave these tags empty</span>
    <span class="keyword">struct</span> <span class="identifier">accurate</span> <span class="special">{};</span>

    <span class="keyword">template</span><span class="special">&lt;&gt;</span>
    <span class="keyword">struct</span> <span class="identifier">as_feature</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">fubar</span><span class="special">(</span><span class="identifier">accurate</span><span class="special">)&gt;</span>
    <span class="special">{</span>
        <span class="keyword">typedef</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">fubar</span> <span class="identifier">type</span><span class="special">;</span>
    <span class="special">};</span>

    <span class="keyword">template</span><span class="special">&lt;&gt;</span>
    <span class="keyword">struct</span> <span class="identifier">as_feature</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">fubar</span><span class="special">(</span><span class="identifier">fast</span><span class="special">)&gt;</span>
    <span class="special">{</span>
        <span class="keyword">typedef</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">fast_fubar</span> <span class="identifier">type</span><span class="special">;</span>
    <span class="special">};</span>
<span class="special">}}</span>
</pre>
<p>
            Once you have done this, users of your fubar accumulator can request
            the <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">fubar</span><span class="special">(</span><span class="identifier">fast</span><span class="special">)</span></code>
            and <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">fubar</span><span class="special">(</span><span class="identifier">accurate</span><span class="special">)</span></code>
            features when defining their <code class="computeroutput"><span class="identifier">accumulator_set</span></code>s
            and get the correct accumulator.
          </p>
</div>
<div class="section">
<div class="titlepage"><div><div><h5 class="title">
<a name="accumulators.user_s_guide.the_accumulators_framework.extending_the_accumulators_framework.operators_ex"></a><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_accumulators_framework.extending_the_accumulators_framework.operators_ex" title="Specializing Numeric Operators">Specializing
          Numeric Operators</a>
</h5></div></div></div>
<p>
            This section describes how to adapt third-party numeric types to work
            with the Accumulator Framework.
          </p>
<p>
            Rather than relying on the built-in operators, the Accumulators Framework
            relies on functions and operator overloads defined in the <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_accumulators_framework.numeric_operators_sub_library" title="Numeric Operators Sub-Library">Numeric
            Operators Sub-Library</a> for many of its numeric operations. This
            is so that it is possible to assign non-standard meanings to arithmetic
            operations. For instance, when calculating an average by dividing two
            integers, the standard integer division behavior would be mathematically
            incorrect for most statistical quantities. So rather than use <code class="computeroutput"><span class="identifier">x</span> <span class="special">/</span> <span class="identifier">y</span></code>, the Accumulators Framework uses
            <code class="computeroutput"><span class="identifier">numeric</span><span class="special">::</span><span class="identifier">fdiv</span><span class="special">(</span><span class="identifier">x</span><span class="special">,</span> <span class="identifier">y</span><span class="special">)</span></code>,
            which does floating-point division even if both <code class="computeroutput"><span class="identifier">x</span></code>
            and <code class="computeroutput"><span class="identifier">y</span></code> are integers.
          </p>
<p>
            Another example where the Numeric Operators Sub-Library is useful is
            when a type does not define the operator overloads required to use it
            for some statistical calculations. For instance, <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;&gt;</span></code> does not overload any arithmetic
            operators, yet it may be useful to use <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;&gt;</span></code> as a sample or variate type.
            The Numeric Operators Sub-Library defines the necessary operator overloads
            in the <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">numeric</span><span class="special">::</span><span class="identifier">operators</span></code> namespace, which is brought
            into scope by the Accumulators Framework with a using directive.
          </p>
<p>
            <span class="bold"><strong>Numeric Function Objects and Tag Dispatching</strong></span>
          </p>
<p>
            How are the numeric function object defined by the Numeric Operators
            Sub-Library made to work with types such as <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;&gt;</span></code>? The free functions in the <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">numeric</span></code> namespace are implemented in
            terms of the function objects in the <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span></code>
            namespace, so to make <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">numeric</span><span class="special">::</span><span class="identifier">fdiv</span><span class="special">()</span></code> do something sensible with a <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;&gt;</span></code>,
            for instance, we'll need to partially specialize the <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">fdiv</span><span class="special">&lt;&gt;</span></code> function object.
          </p>
<p>
            The functional objects make use of a technique known as <a href="http://www.boost.org/community/generic_programming.html#tag_dispatching" target="_top"><span class="emphasis"><em>tag
            dispatching</em></span></a> to select the proper implementation for
            the given operands. It works as follows:
          </p>
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">numeric</span> <span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">functional</span>
<span class="special">{</span>
    <span class="comment">// Metafunction for looking up the tag associated with</span>
    <span class="comment">// a given numeric type T.</span>
    <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">&gt;</span>
    <span class="keyword">struct</span> <span class="identifier">tag</span>
    <span class="special">{</span>
        <span class="comment">// by default, all types have void as a tag type</span>
        <span class="keyword">typedef</span> <span class="keyword">void</span> <span class="identifier">type</span><span class="special">;</span>
    <span class="special">};</span>

    <span class="comment">// Forward declaration looks up the tag types of each operand</span>
    <span class="keyword">template</span><span class="special">&lt;</span>
        <span class="keyword">typename</span> <span class="identifier">Left</span>
      <span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">Right</span>
      <span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">LeftTag</span> <span class="special">=</span> <span class="keyword">typename</span> <span class="identifier">tag</span><span class="special">&lt;</span><span class="identifier">Left</span><span class="special">&gt;::</span><span class="identifier">type</span>
      <span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">RightTag</span> <span class="special">=</span> <span class="keyword">typename</span> <span class="identifier">tag</span><span class="special">&lt;</span><span class="identifier">Right</span><span class="special">&gt;::</span><span class="identifier">type</span>
    <span class="special">&gt;</span>
    <span class="keyword">struct</span> <span class="identifier">fdiv</span><span class="special">;</span>
<span class="special">}}}</span>
</pre>
<p>
            If you have some user-defined type <code class="computeroutput"><span class="identifier">MyDouble</span></code>
            for which you would like to customize the behavior of <code class="computeroutput"><span class="identifier">numeric</span><span class="special">::</span><span class="identifier">fdiv</span><span class="special">()</span></code>, you would specialize <code class="computeroutput"><span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">fdiv</span><span class="special">&lt;&gt;</span></code>
            by first defining a tag type, as shown below:
          </p>
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">numeric</span> <span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">functional</span>
<span class="special">{</span>
    <span class="comment">// Tag type for MyDouble</span>
    <span class="keyword">struct</span> <span class="identifier">MyDoubleTag</span> <span class="special">{};</span>

    <span class="comment">// Specialize tag&lt;&gt; for MyDouble.</span>
    <span class="comment">// This only needs to be done once.</span>
    <span class="keyword">template</span><span class="special">&lt;&gt;</span>
    <span class="keyword">struct</span> <span class="identifier">tag</span><span class="special">&lt;</span><span class="identifier">MyDouble</span><span class="special">&gt;</span>
    <span class="special">{</span>
        <span class="keyword">typedef</span> <span class="identifier">MyDoubleTag</span> <span class="identifier">type</span><span class="special">;</span>
    <span class="special">};</span>

    <span class="comment">// Specify how to divide a MyDouble by an integral count</span>
    <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Left</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">Right</span><span class="special">&gt;</span>
    <span class="keyword">struct</span> <span class="identifier">fdiv</span><span class="special">&lt;</span><span class="identifier">Left</span><span class="special">,</span> <span class="identifier">Right</span><span class="special">,</span> <span class="identifier">MyDoubleTag</span><span class="special">,</span> <span class="keyword">void</span><span class="special">&gt;</span>
    <span class="special">{</span>
        <span class="comment">// Define the type of the result</span>
        <span class="keyword">typedef</span> <span class="special">...</span> <span class="identifier">result_type</span><span class="special">;</span>

        <span class="identifier">result_type</span> <span class="keyword">operator</span><span class="special">()(</span><span class="identifier">Left</span> <span class="special">&amp;</span> <span class="identifier">left</span><span class="special">,</span> <span class="identifier">Right</span> <span class="special">&amp;</span> <span class="identifier">right</span><span class="special">)</span> <span class="keyword">const</span>
        <span class="special">{</span>
            <span class="keyword">return</span> <span class="special">...;</span>
        <span class="special">}</span>
    <span class="special">};</span>
<span class="special">}}}</span>
</pre>
<p>
            Once you have done this, <code class="computeroutput"><span class="identifier">numeric</span><span class="special">::</span><span class="identifier">fdiv</span><span class="special">()</span></code> will use your specialization of <code class="computeroutput"><span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">fdiv</span><span class="special">&lt;&gt;</span></code>
            when the first argument is a <code class="computeroutput"><span class="identifier">MyDouble</span></code>
            object. All of the function objects in the Numeric Operators Sub-Library
            can be customized in a similar fashion.
          </p>
</div>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="accumulators.user_s_guide.the_accumulators_framework.concepts"></a><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_accumulators_framework.concepts" title="Concepts">Concepts</a>
</h4></div></div></div>
<h3>
<a name="accumulators.user_s_guide.the_accumulators_framework.concepts.h0"></a>
          <span class="phrase"><a name="accumulators.user_s_guide.the_accumulators_framework.concepts.accumulator_concept"></a></span><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_accumulators_framework.concepts.accumulator_concept">Accumulator
          Concept</a>
        </h3>
<p>
          In the following table, <code class="computeroutput"><span class="identifier">Acc</span></code>
          is the type of an accumulator, <code class="computeroutput"><span class="identifier">acc</span></code>
          and <code class="computeroutput"><span class="identifier">acc2</span></code> are objects of
          type <code class="computeroutput"><span class="identifier">Acc</span></code>, and <code class="computeroutput"><span class="identifier">args</span></code> is the name of an argument pack
          from the <a href="../../../libs/parameter/index.html" target="_top">Boost.Parameter</a>
          library.
        </p>
<div class="table">
<a name="accumulators.user_s_guide.the_accumulators_framework.concepts.t0"></a><p class="title"><b>Table 1.2. Accumulator Requirements</b></p>
<div class="table-contents"><table class="table" summary="Accumulator Requirements">
<colgroup>
<col>
<col>
<col>
</colgroup>
<thead><tr>
<th>
                  <p>
                    <span class="bold"><strong>Expression</strong></span>
                  </p>
                </th>
<th>
                  <p>
                    <span class="bold"><strong>Return type</strong></span>
                  </p>
                </th>
<th>
                  <p>
                    <span class="bold"><strong>Assertion / Note / Pre- / Post-condition</strong></span>
                  </p>
                </th>
</tr></thead>
<tbody>
<tr>
<td>
                  <p>
                    <code class="computeroutput"><span class="identifier">Acc</span><span class="special">::</span><span class="identifier">result_type</span></code>
                  </p>
                </td>
<td>
                  <p>
                    <span class="emphasis"><em>implementation defined</em></span>
                  </p>
                </td>
<td>
                  <p>
                    The type returned by <code class="computeroutput"><span class="identifier">Acc</span><span class="special">::</span><span class="identifier">result</span><span class="special">()</span></code>.
                  </p>
                </td>
</tr>
<tr>
<td>
                  <p>
                    <code class="computeroutput"><span class="identifier">Acc</span> <span class="identifier">acc</span><span class="special">(</span><span class="identifier">args</span><span class="special">)</span></code>
                  </p>
                </td>
<td>
                  <p>
                    none
                  </p>
                </td>
<td>
                  <p>
                    Construct from an argument pack.
                  </p>
                </td>
</tr>
<tr>
<td>
                  <p>
                    <code class="computeroutput"><span class="identifier">Acc</span> <span class="identifier">acc</span><span class="special">(</span><span class="identifier">acc2</span><span class="special">)</span></code>
                  </p>
                </td>
<td>
                  <p>
                    none
                  </p>
                </td>
<td>
                  <p>
                    Post: <code class="computeroutput"><span class="identifier">acc</span><span class="special">.</span><span class="identifier">result</span><span class="special">(</span><span class="identifier">args</span><span class="special">)</span></code>
                    is equivalent to <code class="computeroutput"><span class="identifier">acc2</span><span class="special">.</span><span class="identifier">result</span><span class="special">(</span><span class="identifier">args</span><span class="special">)</span></code>
                  </p>
                </td>
</tr>
<tr>
<td>
                  <p>
                    <code class="computeroutput"><span class="identifier">acc</span><span class="special">(</span><span class="identifier">args</span><span class="special">)</span></code>
                  </p>
                </td>
<td>
                  <p>
                    <span class="emphasis"><em>unspecified</em></span>
                  </p>
                </td>
<td>
                </td>
</tr>
<tr>
<td>
                  <p>
                    <code class="computeroutput"><span class="identifier">acc</span><span class="special">.</span><span class="identifier">on_drop</span><span class="special">(</span><span class="identifier">args</span><span class="special">)</span></code>
                  </p>
                </td>
<td>
                  <p>
                    <span class="emphasis"><em>unspecified</em></span>
                  </p>
                </td>
<td>
                </td>
</tr>
<tr>
<td>
                  <p>
                    <code class="computeroutput"><span class="identifier">acc</span><span class="special">.</span><span class="identifier">result</span><span class="special">(</span><span class="identifier">args</span><span class="special">)</span></code>
                  </p>
                </td>
<td>
                  <p>
                    <code class="computeroutput"><span class="identifier">Acc</span><span class="special">::</span><span class="identifier">result_type</span></code>
                  </p>
                </td>
<td>
                </td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break"><h3>
<a name="accumulators.user_s_guide.the_accumulators_framework.concepts.h1"></a>
          <span class="phrase"><a name="accumulators.user_s_guide.the_accumulators_framework.concepts.feature_concept"></a></span><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_accumulators_framework.concepts.feature_concept">Feature
          Concept</a>
        </h3>
<p>
          In the following table, <code class="computeroutput"><span class="identifier">F</span></code>
          is the type of a feature and <code class="computeroutput"><span class="identifier">S</span></code>
          is some scalar type.
        </p>
<div class="table">
<a name="accumulators.user_s_guide.the_accumulators_framework.concepts.t1"></a><p class="title"><b>Table 1.3. Feature Requirements</b></p>
<div class="table-contents"><table class="table" summary="Feature Requirements">
<colgroup>
<col>
<col>
<col>
</colgroup>
<thead><tr>
<th>
                  <p>
                    <span class="bold"><strong>Expression</strong></span>
                  </p>
                </th>
<th>
                  <p>
                    <span class="bold"><strong>Return type</strong></span>
                  </p>
                </th>
<th>
                  <p>
                    <span class="bold"><strong>Assertion / Note / Pre- / Post-condition</strong></span>
                  </p>
                </th>
</tr></thead>
<tbody>
<tr>
<td>
                  <p>
                    <code class="computeroutput"><span class="identifier">F</span><span class="special">::</span><span class="identifier">dependencies</span></code>
                  </p>
                </td>
<td>
                  <p>
                    <span class="emphasis"><em>unspecified</em></span>
                  </p>
                </td>
<td>
                  <p>
                    An MPL sequence of other features on which <code class="computeroutput"><span class="identifier">F</span></code>
                    depends.
                  </p>
                </td>
</tr>
<tr>
<td>
                  <p>
                    <code class="computeroutput"><span class="identifier">F</span><span class="special">::</span><span class="identifier">is_weight_accumulator</span></code>
                  </p>
                </td>
<td>
                  <p>
                    <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">true_</span></code> or <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">false_</span></code>
                  </p>
                </td>
<td>
                  <p>
                    <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">true_</span></code> if the accumulator for
                    this feature should be made external when the weight type for
                    the accumulator set is <code class="computeroutput"><span class="identifier">external</span><span class="special">&lt;</span><span class="identifier">S</span><span class="special">&gt;</span></code>, <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">false_</span></code>
                    otherwise.
                  </p>
                </td>
</tr>
<tr>
<td>
                  <p>
                    <code class="computeroutput"><span class="identifier">F</span><span class="special">::</span><span class="identifier">impl</span></code>
                  </p>
                </td>
<td>
                  <p>
                    <span class="emphasis"><em>unspecified</em></span>
                  </p>
                </td>
<td>
                  <p>
                    An <a href="../../../libs/mpl/doc/refmanual/lambda-expression.html" target="_top">MPL
                    Lambda Expression</a> that returns the type of the accumulator
                    that implements this feature when passed a sample type and a
                    weight type.
                  </p>
                </td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break">
</div>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="accumulators.user_s_guide.the_statistical_accumulators_library"></a><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library" title="The Statistical Accumulators Library">The
      Statistical Accumulators Library</a>
</h3></div></div></div>
<div class="toc"><dl class="toc">
<dt><span class="section"><a href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.count">count</a></span></dt>
<dt><span class="section"><a href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.covariance">covariance</a></span></dt>
<dt><span class="section"><a href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.density">density</a></span></dt>
<dt><span class="section"><a href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.error_of_mean">error_of&lt;mean&gt;</a></span></dt>
<dt><span class="section"><a href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.extended_p_square">extended_p_square</a></span></dt>
<dt><span class="section"><a href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.extended_p_square_quantile">extended_p_square_quantile
        <span class="emphasis"><em>and variants</em></span></a></span></dt>
<dt><span class="section"><a href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.kurtosis">kurtosis</a></span></dt>
<dt><span class="section"><a href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.max">max</a></span></dt>
<dt><span class="section"><a href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.mean">mean
        <span class="emphasis"><em>and variants</em></span></a></span></dt>
<dt><span class="section"><a href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.median">median
        <span class="emphasis"><em>and variants</em></span></a></span></dt>
<dt><span class="section"><a href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.min">min</a></span></dt>
<dt><span class="section"><a href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.moment">moment</a></span></dt>
<dt><span class="section"><a href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.p_square_cumulative_distribution">p_square_cumulative_distribution</a></span></dt>
<dt><span class="section"><a href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.p_square_quantile">p_square_quantile
        <span class="emphasis"><em>and variants</em></span></a></span></dt>
<dt><span class="section"><a href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.peaks_over_threshold">peaks_over_threshold
        <span class="emphasis"><em>and variants</em></span></a></span></dt>
<dt><span class="section"><a href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.pot_quantile">pot_quantile
        <span class="emphasis"><em>and variants</em></span></a></span></dt>
<dt><span class="section"><a href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.pot_tail_mean">pot_tail_mean</a></span></dt>
<dt><span class="section"><a href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.rolling_count">rolling_count</a></span></dt>
<dt><span class="section"><a href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.rolling_sum">rolling_sum</a></span></dt>
<dt><span class="section"><a href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.rolling_mean">rolling_mean</a></span></dt>
<dt><span class="section"><a href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.rolling_moment">rolling_moment</a></span></dt>
<dt><span class="section"><a href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.rolling_variance">rolling_variance</a></span></dt>
<dt><span class="section"><a href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.skewness">skewness</a></span></dt>
<dt><span class="section"><a href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.sum">sum
        <span class="emphasis"><em>and variants</em></span></a></span></dt>
<dt><span class="section"><a href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.tail">tail</a></span></dt>
<dt><span class="section"><a href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.coherent_tail_mean">coherent_tail_mean</a></span></dt>
<dt><span class="section"><a href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.non_coherent_tail_mean">non_coherent_tail_mean</a></span></dt>
<dt><span class="section"><a href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.tail_quantile">tail_quantile</a></span></dt>
<dt><span class="section"><a href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.tail_variate">tail_variate</a></span></dt>
<dt><span class="section"><a href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.tail_variate_means">tail_variate_means
        <span class="emphasis"><em>and variants</em></span></a></span></dt>
<dt><span class="section"><a href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.variance">variance
        <span class="emphasis"><em>and variants</em></span></a></span></dt>
<dt><span class="section"><a href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.weighted_covariance">weighted_covariance</a></span></dt>
<dt><span class="section"><a href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.weighted_density">weighted_density</a></span></dt>
<dt><span class="section"><a href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.weighted_extended_p_square">weighted_extended_p_square</a></span></dt>
<dt><span class="section"><a href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.weighted_kurtosis">weighted_kurtosis</a></span></dt>
<dt><span class="section"><a href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.weighted_mean">weighted_mean
        <span class="emphasis"><em>and variants</em></span></a></span></dt>
<dt><span class="section"><a href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.weighted_median">weighted_median
        <span class="emphasis"><em>and variants</em></span></a></span></dt>
<dt><span class="section"><a href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.weighted_moment">weighted_moment</a></span></dt>
<dt><span class="section"><a href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.weighted_p_square_cumulative_distribution">weighted_p_square_cumulative_distribution</a></span></dt>
<dt><span class="section"><a href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.weighted_p_square_quantile">weighted_p_square_quantile
        <span class="emphasis"><em>and variants</em></span></a></span></dt>
<dt><span class="section"><a href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.weighted_peaks_over_threshold">weighted_peaks_over_threshold
        <span class="emphasis"><em>and variants</em></span></a></span></dt>
<dt><span class="section"><a href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.weighted_skewness">weighted_skewness</a></span></dt>
<dt><span class="section"><a href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.weighted_sum">weighted_sum
        <span class="emphasis"><em>and variants</em></span></a></span></dt>
<dt><span class="section"><a href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.non_coherent_weighted_tail_mean">non_coherent_weighted_tail_mean</a></span></dt>
<dt><span class="section"><a href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.weighted_tail_quantile">weighted_tail_quantile</a></span></dt>
<dt><span class="section"><a href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.weighted_tail_variate_means">weighted_tail_variate_means
        <span class="emphasis"><em>and variants</em></span></a></span></dt>
<dt><span class="section"><a href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.weighted_variance">weighted_variance
        <span class="emphasis"><em>and variants</em></span></a></span></dt>
</dl></div>
<p>
        The Statistical Accumulators Library defines accumulators for incremental
        statistical computations. It is built on top of <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_accumulators_framework" title="The Accumulators Framework">The
        Accumulator Framework</a>.
      </p>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="accumulators.user_s_guide.the_statistical_accumulators_library.count"></a><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.count" title="count">count</a>
</h4></div></div></div>
<p>
          The <code class="computeroutput"><span class="identifier">count</span></code> feature is a
          simple counter that tracks the number of samples pushed into the accumulator
          set.
        </p>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Result Type</span></dt>
<dd>
<p>
</p>
<pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span>
</pre>
<p>
              </p>
</dd>
<dt><span class="term">Depends On</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Variants</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Initialization Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Accumulator Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Extractor Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Accumulator Complexity</span></dt>
<dd><p>
                O(1)
              </p></dd>
<dt><span class="term">Extractor Complexity</span></dt>
<dd><p>
                O(1)
              </p></dd>
</dl>
</div>
<p>
          <span class="bold"><strong>Header</strong></span>
        </p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><code class="computeroutput"><a class="link" href="reference.html#header.boost.accumulators.statistics.count_hpp" title="Header &lt;boost/accumulators/statistics/count.hpp&gt;">boost/accumulators/statistics/count.hpp</a></code><span class="special">&gt;</span>
</pre>
<p>
          <span class="bold"><strong>Example</strong></span>
        </p>
<pre class="programlisting"><span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">,</span> <span class="identifier">features</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">count</span><span class="special">&gt;</span> <span class="special">&gt;</span> <span class="identifier">acc</span><span class="special">;</span>
<span class="identifier">acc</span><span class="special">(</span><span class="number">0</span><span class="special">);</span>
<span class="identifier">acc</span><span class="special">(</span><span class="number">0</span><span class="special">);</span>
<span class="identifier">acc</span><span class="special">(</span><span class="number">0</span><span class="special">);</span>
<span class="identifier">assert</span><span class="special">(</span><span class="number">3</span> <span class="special">==</span> <span class="identifier">count</span><span class="special">(</span><span class="identifier">acc</span><span class="special">));</span>
</pre>
<p>
          <span class="bold"><strong>See also</strong></span>
        </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
              <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/count_impl.html" title="Struct count_impl">count_impl</a></code>
            </li></ul></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="accumulators.user_s_guide.the_statistical_accumulators_library.covariance"></a><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.covariance" title="covariance">covariance</a>
</h4></div></div></div>
<p>
          The <code class="computeroutput"><span class="identifier">covariance</span></code> feature
          is an iterative Monte Carlo estimator for the covariance. It is specified
          as <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">covariance</span><span class="special">&lt;</span><em class="replaceable"><code>variate-type</code></em><span class="special">,</span> <em class="replaceable"><code>variate-tag</code></em><span class="special">&gt;</span></code>.
        </p>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Result Type</span></dt>
<dd>
<p>
</p>
<pre class="programlisting"><span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">outer_product</span><span class="special">&lt;</span>
    <span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">fdiv</span><span class="special">&lt;</span><em class="replaceable"><code>sample-type</code></em><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">&gt;::</span><span class="identifier">result_type</span>
  <span class="special">,</span> <span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">fdiv</span><span class="special">&lt;</span><em class="replaceable"><code>variate-type</code></em><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">&gt;::</span><span class="identifier">result_type</span>
<span class="special">&gt;::</span><span class="identifier">result_type</span>
</pre>
<p>
              </p>
</dd>
<dt><span class="term">Depends On</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">count</span></code> <br> <code class="computeroutput"><span class="identifier">mean</span></code> <br> <code class="computeroutput"><span class="identifier">mean_of_variates</span><span class="special">&lt;</span><em class="replaceable"><code>variate-type</code></em><span class="special">,</span> <em class="replaceable"><code>variate-tag</code></em><span class="special">&gt;</span></code>
              </p></dd>
<dt><span class="term">Variants</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">abstract_covariance</span></code>
              </p></dd>
<dt><span class="term">Initialization Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Accumulator Parameters</span></dt>
<dd><p>
                <em class="replaceable"><code>variate-tag</code></em>
              </p></dd>
<dt><span class="term">Extractor Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Accumulator Complexity</span></dt>
<dd><p>
                TODO
              </p></dd>
<dt><span class="term">Extractor Complexity</span></dt>
<dd><p>
                O(1)
              </p></dd>
</dl>
</div>
<p>
          <span class="bold"><strong>Headers</strong></span>
        </p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><code class="computeroutput"><a class="link" href="reference.html#header.boost.accumulators.statistics.covariance_hpp" title="Header &lt;boost/accumulators/statistics/covariance.hpp&gt;">boost/accumulators/statistics/covariance.hpp</a></code><span class="special">&gt;</span>
<span class="preprocessor">#include</span> <span class="special">&lt;</span><code class="computeroutput"><a class="link" href="reference.html#header.boost.accumulators.statistics.variates.covariate_hpp" title="Header &lt;boost/accumulators/statistics/variates/covariate.hpp&gt;">boost/accumulators/statistics/variates/covariate.hpp</a></code><span class="special">&gt;</span>
</pre>
<p>
          <span class="bold"><strong>Example</strong></span>
        </p>
<pre class="programlisting"><span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">covariance</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">,</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">covariate1</span><span class="special">&gt;</span> <span class="special">&gt;</span> <span class="special">&gt;</span> <span class="identifier">acc</span><span class="special">;</span>
<span class="identifier">acc</span><span class="special">(</span><span class="number">1.</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="number">2.</span><span class="special">);</span>
<span class="identifier">acc</span><span class="special">(</span><span class="number">1.</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="number">4.</span><span class="special">);</span>
<span class="identifier">acc</span><span class="special">(</span><span class="number">2.</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="number">3.</span><span class="special">);</span>
<span class="identifier">acc</span><span class="special">(</span><span class="number">6.</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="number">1.</span><span class="special">);</span>
<span class="identifier">assert</span><span class="special">(</span><span class="identifier">covariance</span><span class="special">(</span><span class="identifier">acc</span><span class="special">)</span> <span class="special">==</span> <span class="special">-</span><span class="number">1.75</span><span class="special">);</span>
</pre>
<p>
          <span class="bold"><strong>See also</strong></span>
        </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
              <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/covariance_impl.html" title="Struct template covariance_impl">covariance_impl</a></code>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.count" title="count"><code class="literal">count</code></a>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.mean" title="mean and variants"><code class="literal">mean</code></a>
            </li>
</ul></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="accumulators.user_s_guide.the_statistical_accumulators_library.density"></a><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.density" title="density">density</a>
</h4></div></div></div>
<p>
          The <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">density</span></code> feature returns a histogram of
          the sample distribution. For more implementation details, see <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/density_impl.html" title="Struct template density_impl">density_impl</a></code>.
        </p>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Result Type</span></dt>
<dd>
<p>
</p>
<pre class="programlisting"><span class="identifier">iterator_range</span><span class="special">&lt;</span>
    <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span>
        <span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special">&lt;</span>
            <span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">fdiv</span><span class="special">&lt;</span><em class="replaceable"><code>sample-type</code></em><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">&gt;::</span><span class="identifier">result_type</span>
          <span class="special">,</span> <span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">fdiv</span><span class="special">&lt;</span><em class="replaceable"><code>sample-type</code></em><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">&gt;::</span><span class="identifier">result_type</span>
        <span class="special">&gt;</span>
    <span class="special">&gt;::</span><span class="identifier">iterator</span>
<span class="special">&gt;</span>
</pre>
<p>
              </p>
</dd>
<dt><span class="term">Depends On</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">count</span></code> <br> <code class="computeroutput"><span class="identifier">min</span></code> <br> <code class="computeroutput"><span class="identifier">max</span></code>
              </p></dd>
<dt><span class="term">Variants</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Initialization Parameters</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">density</span><span class="special">::</span><span class="identifier">cache_size</span></code> <br> <code class="computeroutput"><span class="identifier">density</span><span class="special">::</span><span class="identifier">num_bins</span></code>
              </p></dd>
<dt><span class="term">Accumulator Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Extractor Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Accumulator Complexity</span></dt>
<dd><p>
                TODO
              </p></dd>
<dt><span class="term">Extractor Complexity</span></dt>
<dd><p>
                O(N), when N is <code class="computeroutput"><span class="identifier">density</span><span class="special">::</span><span class="identifier">num_bins</span></code>
              </p></dd>
</dl>
</div>
<p>
          <span class="bold"><strong>Header</strong></span>
        </p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><code class="computeroutput"><a class="link" href="reference.html#header.boost.accumulators.statistics.density_hpp" title="Header &lt;boost/accumulators/statistics/density.hpp&gt;">boost/accumulators/statistics/density.hpp</a></code><span class="special">&gt;</span>
</pre>
<p>
          <span class="bold"><strong>Note</strong></span>
        </p>
<p>
          Results from the <code class="computeroutput"><span class="identifier">density</span></code>
          accumulator can only be extracted after the number of samples meets or
          exceeds the cache size.
        </p>
<p>
          <span class="bold"><strong>See also</strong></span>
        </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
              <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/density_impl.html" title="Struct template density_impl">density_impl</a></code>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.count" title="count"><code class="literal">count</code></a>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.min" title="min"><code class="literal">min</code></a>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.max" title="max"><code class="literal">max</code></a>
            </li>
</ul></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="accumulators.user_s_guide.the_statistical_accumulators_library.error_of_mean"></a><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.error_of_mean" title="error_of&lt;mean&gt;">error_of&lt;mean&gt;</a>
</h4></div></div></div>
<p>
          The <code class="computeroutput"><span class="identifier">error_of</span><span class="special">&lt;</span><span class="identifier">mean</span><span class="special">&gt;</span></code>
          feature calculates the error of the mean feature. It is equal to <code class="computeroutput"><span class="identifier">sqrt</span><span class="special">(</span><span class="identifier">variance</span> <span class="special">/</span>
          <span class="special">(</span><span class="identifier">count</span>
          <span class="special">-</span> <span class="number">1</span><span class="special">))</span></code>.
        </p>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Result Type</span></dt>
<dd>
<p>
</p>
<pre class="programlisting"><span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">fdiv</span><span class="special">&lt;</span><em class="replaceable"><code>sample-type</code></em><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">&gt;::</span><span class="identifier">result_type</span>
</pre>
<p>
              </p>
</dd>
<dt><span class="term">Depends On</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">count</span></code> <br> <code class="computeroutput"><span class="identifier">variance</span></code>
              </p></dd>
<dt><span class="term">Variants</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">error_of</span><span class="special">&lt;</span><span class="identifier">immediate_mean</span><span class="special">&gt;</span></code>
              </p></dd>
<dt><span class="term">Initialization Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Accumulator Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Extractor Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Accumulator Complexity</span></dt>
<dd><p>
                TODO
              </p></dd>
<dt><span class="term">Extractor Complexity</span></dt>
<dd><p>
                O(1)
              </p></dd>
</dl>
</div>
<p>
          <span class="bold"><strong>Header</strong></span>
        </p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><code class="computeroutput"><a class="link" href="reference.html#header.boost.accumulators.statistics.error_of_hpp" title="Header &lt;boost/accumulators/statistics/error_of.hpp&gt;">boost/accumulators/statistics/error_of.hpp</a></code><span class="special">&gt;</span>
<span class="preprocessor">#include</span> <span class="special">&lt;</span><code class="computeroutput"><a class="link" href="reference.html#header.boost.accumulators.statistics.error_of_mean_hpp" title="Header &lt;boost/accumulators/statistics/error_of_mean.hpp&gt;">boost/accumulators/statistics/error_of_mean.hpp</a></code><span class="special">&gt;</span>
</pre>
<p>
          <span class="bold"><strong>Example</strong></span>
        </p>
<pre class="programlisting"><span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">error_of</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">mean</span><span class="special">&gt;</span> <span class="special">&gt;</span> <span class="special">&gt;</span> <span class="identifier">acc</span><span class="special">;</span>
<span class="identifier">acc</span><span class="special">(</span><span class="number">1.1</span><span class="special">);</span>
<span class="identifier">acc</span><span class="special">(</span><span class="number">1.2</span><span class="special">);</span>
<span class="identifier">acc</span><span class="special">(</span><span class="number">1.3</span><span class="special">);</span>
<span class="identifier">assert</span><span class="special">(</span><span class="number">0.057735</span> <span class="special">==</span> <span class="identifier">error_of</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">mean</span><span class="special">&gt;(</span><span class="identifier">acc</span><span class="special">));</span>
</pre>
<p>
          <span class="bold"><strong>See also</strong></span>
        </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
              <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/error_of_mean_impl.html" title="Struct template error_of_mean_impl">error_of_mean_impl</a></code>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.count" title="count"><code class="literal">count</code></a>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.variance" title="variance and variants"><code class="literal">variance</code></a>
            </li>
</ul></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="accumulators.user_s_guide.the_statistical_accumulators_library.extended_p_square"></a><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.extended_p_square" title="extended_p_square">extended_p_square</a>
</h4></div></div></div>
<p>
          Multiple quantile estimation with the extended <code class="literal">P^2</code> algorithm.
          For further details, see <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/extended_p_square_impl.html" title="Struct template extended_p_square_impl">extended_p_square_impl</a></code>.
        </p>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Result Type</span></dt>
<dd>
<p>
</p>
<pre class="programlisting"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">iterator_range</span><span class="special">&lt;</span>
    <em class="replaceable"><code>implementation-defined</code></em>
<span class="special">&gt;</span>
</pre>
<p>
              </p>
</dd>
<dt><span class="term">Depends On</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">count</span></code>
              </p></dd>
<dt><span class="term">Variants</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Initialization Parameters</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">extended_p_square</span><span class="special">::</span><span class="identifier">probabilities</span></code>
              </p></dd>
<dt><span class="term">Accumulator Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Extractor Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Accumulator Complexity</span></dt>
<dd><p>
                TODO
              </p></dd>
<dt><span class="term">Extractor Complexity</span></dt>
<dd><p>
                O(1)
              </p></dd>
</dl>
</div>
<p>
          <span class="bold"><strong>Header</strong></span>
        </p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><code class="computeroutput"><a class="link" href="reference.html#header.boost.accumulators.statistics.extended_p_square_hpp" title="Header &lt;boost/accumulators/statistics/extended_p_square.hpp&gt;">boost/accumulators/statistics/extended_p_square.hpp</a></code><span class="special">&gt;</span>
</pre>
<p>
          <span class="bold"><strong>Example</strong></span>
        </p>
<pre class="programlisting"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">array</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;</span> <span class="identifier">probs</span> <span class="special">=</span> <span class="special">{</span><span class="number">0.001</span><span class="special">,</span><span class="number">0.01</span><span class="special">,</span><span class="number">0.1</span><span class="special">,</span><span class="number">0.25</span><span class="special">,</span><span class="number">0.5</span><span class="special">,</span><span class="number">0.75</span><span class="special">,</span><span class="number">0.9</span><span class="special">,</span><span class="number">0.99</span><span class="special">,</span><span class="number">0.999</span><span class="special">};</span>
<span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">extended_p_square</span><span class="special">&gt;</span> <span class="special">&gt;</span>
    <span class="identifier">acc</span><span class="special">(</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">extended_p_square</span><span class="special">::</span><span class="identifier">probabilities</span> <span class="special">=</span> <span class="identifier">probs</span><span class="special">);</span>

<span class="identifier">boost</span><span class="special">::</span><span class="identifier">lagged_fibonacci607</span> <span class="identifier">rng</span><span class="special">;</span> <span class="comment">// a random number generator</span>
<span class="keyword">for</span> <span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span><span class="special">=</span><span class="number">0</span><span class="special">;</span> <span class="identifier">i</span><span class="special">&lt;</span><span class="number">10000</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
    <span class="identifier">acc</span><span class="special">(</span><span class="identifier">rng</span><span class="special">());</span>

<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span><span class="identifier">extended_p_square</span><span class="special">(</span><span class="identifier">acc</span><span class="special">)[</span><span class="number">0</span><span class="special">],</span> <span class="identifier">probs</span><span class="special">[</span><span class="number">0</span><span class="special">],</span> <span class="number">25</span><span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span><span class="identifier">extended_p_square</span><span class="special">(</span><span class="identifier">acc</span><span class="special">)[</span><span class="number">1</span><span class="special">],</span> <span class="identifier">probs</span><span class="special">[</span><span class="number">1</span><span class="special">],</span> <span class="number">10</span><span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span><span class="identifier">extended_p_square</span><span class="special">(</span><span class="identifier">acc</span><span class="special">)[</span><span class="number">2</span><span class="special">],</span> <span class="identifier">probs</span><span class="special">[</span><span class="number">2</span><span class="special">],</span> <span class="number">5</span><span class="special">);</span>

<span class="keyword">for</span> <span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">i</span><span class="special">=</span><span class="number">3</span><span class="special">;</span> <span class="identifier">i</span> <span class="special">&lt;</span> <span class="identifier">probs</span><span class="special">.</span><span class="identifier">size</span><span class="special">();</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
<span class="special">{</span>
    <span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span><span class="identifier">extended_p_square</span><span class="special">(</span><span class="identifier">acc</span><span class="special">)[</span><span class="identifier">i</span><span class="special">],</span> <span class="identifier">probs</span><span class="special">[</span><span class="identifier">i</span><span class="special">],</span> <span class="number">2</span><span class="special">);</span>
<span class="special">}</span>
</pre>
<p>
          <span class="bold"><strong>See also</strong></span>
        </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
              <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/extended_p_square_impl.html" title="Struct template extended_p_square_impl">extended_p_square_impl</a></code>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.count" title="count"><code class="literal">count</code></a>
            </li>
</ul></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="accumulators.user_s_guide.the_statistical_accumulators_library.extended_p_square_quantile"></a><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.extended_p_square_quantile" title="extended_p_square_quantile and variants">extended_p_square_quantile
        <span class="emphasis"><em>and variants</em></span></a>
</h4></div></div></div>
<p>
          Quantile estimation using the extended <code class="literal">P^2</code> algorithm
          for weighted and unweighted samples. By default, the calculation is linear
          and unweighted, but quadratic and weighted variants are also provided.
          For further implementation details, see <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/exten_1_3_2_6_3_9_1_1_12_1.html" title="Struct template extended_p_square_quantile_impl">extended_p_square_quantile_impl</a></code>.
        </p>
<p>
          All the variants share the <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">quantile</span></code>
          feature and can be extracted using the <code class="computeroutput"><span class="identifier">quantile</span><span class="special">()</span></code> extractor.
        </p>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Result Type</span></dt>
<dd>
<p>
</p>
<pre class="programlisting"><span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">fdiv</span><span class="special">&lt;</span><em class="replaceable"><code>sample-type</code></em><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">&gt;::</span><span class="identifier">result_type</span>
</pre>
<p>
              </p>
</dd>
<dt><span class="term">Depends On</span></dt>
<dd><p>
                weighted variants depend on <code class="computeroutput"><span class="identifier">weighted_extended_p_square</span></code>
                <br> unweighted variants depend on <code class="computeroutput"><span class="identifier">extended_p_square</span></code>
              </p></dd>
<dt><span class="term">Variants</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">extended_p_square_quantile_quadratic</span></code>
                <br> <code class="computeroutput"><span class="identifier">weighted_extended_p_square_quantile</span></code>
                <br> <code class="computeroutput"><span class="identifier">weighted_extended_p_square_quantile_quadratic</span></code>
              </p></dd>
<dt><span class="term">Initialization Parameters</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">extended_p_square</span><span class="special">::</span><span class="identifier">probabilities</span></code>
              </p></dd>
<dt><span class="term">Accumulator Parameters</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">weight</span></code> for the weighted
                variants
              </p></dd>
<dt><span class="term">Extractor Parameters</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">quantile_probability</span></code>
              </p></dd>
<dt><span class="term">Accumulator Complexity</span></dt>
<dd><p>
                TODO
              </p></dd>
<dt><span class="term">Extractor Complexity</span></dt>
<dd><p>
                O(N) where N is the count of probabilities.
              </p></dd>
</dl>
</div>
<p>
          <span class="bold"><strong>Header</strong></span>
        </p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><code class="computeroutput"><a class="link" href="reference.html#header.boost.accumulators.statistics.extended_p_square_quantile_hpp" title="Header &lt;boost/accumulators/statistics/extended_p_square_quantile.hpp&gt;">boost/accumulators/statistics/extended_p_square_quantile.hpp</a></code><span class="special">&gt;</span>
</pre>
<p>
          <span class="bold"><strong>Example</strong></span>
        </p>
<pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">extended_p_square_quantile</span><span class="special">&gt;</span> <span class="special">&gt;</span>
    <span class="identifier">accumulator_t</span><span class="special">;</span>
<span class="keyword">typedef</span> <span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_extended_p_square_quantile</span><span class="special">&gt;,</span> <span class="keyword">double</span> <span class="special">&gt;</span>
    <span class="identifier">accumulator_t_weighted</span><span class="special">;</span>
<span class="keyword">typedef</span> <span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">extended_p_square_quantile</span><span class="special">(</span><span class="identifier">quadratic</span><span class="special">)&gt;</span> <span class="special">&gt;</span>
    <span class="identifier">accumulator_t_quadratic</span><span class="special">;</span>
<span class="keyword">typedef</span> <span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_extended_p_square_quantile</span><span class="special">(</span><span class="identifier">quadratic</span><span class="special">)&gt;,</span> <span class="keyword">double</span> <span class="special">&gt;</span>
    <span class="identifier">accumulator_t_weighted_quadratic</span><span class="special">;</span>

<span class="comment">// tolerance</span>
<span class="keyword">double</span> <span class="identifier">epsilon</span> <span class="special">=</span> <span class="number">1</span><span class="special">;</span>

<span class="comment">// a random number generator</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">lagged_fibonacci607</span> <span class="identifier">rng</span><span class="special">;</span>

<span class="identifier">boost</span><span class="special">::</span><span class="identifier">array</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;</span> <span class="identifier">probs</span> <span class="special">=</span> <span class="special">{</span> <span class="number">0.990</span><span class="special">,</span> <span class="number">0.991</span><span class="special">,</span> <span class="number">0.992</span><span class="special">,</span> <span class="number">0.993</span><span class="special">,</span> <span class="number">0.994</span><span class="special">,</span>
                               <span class="number">0.995</span><span class="special">,</span> <span class="number">0.996</span><span class="special">,</span> <span class="number">0.997</span><span class="special">,</span> <span class="number">0.998</span><span class="special">,</span> <span class="number">0.999</span> <span class="special">};</span>
<span class="identifier">accumulator_t</span> <span class="identifier">acc</span><span class="special">(</span><span class="identifier">extended_p_square_probabilities</span> <span class="special">=</span> <span class="identifier">probs</span><span class="special">);</span>
<span class="identifier">accumulator_t_weighted</span> <span class="identifier">acc_weighted</span><span class="special">(</span><span class="identifier">extended_p_square_probabilities</span> <span class="special">=</span> <span class="identifier">probs</span><span class="special">);</span>
<span class="identifier">accumulator_t_quadratic</span> <span class="identifier">acc2</span><span class="special">(</span><span class="identifier">extended_p_square_probabilities</span> <span class="special">=</span> <span class="identifier">probs</span><span class="special">);</span>
<span class="identifier">accumulator_t_weighted_quadratic</span> <span class="identifier">acc_weighted2</span><span class="special">(</span><span class="identifier">extended_p_square_probabilities</span> <span class="special">=</span> <span class="identifier">probs</span><span class="special">);</span>

<span class="keyword">for</span> <span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span><span class="special">=</span><span class="number">0</span><span class="special">;</span> <span class="identifier">i</span><span class="special">&lt;</span><span class="number">10000</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
<span class="special">{</span>
    <span class="keyword">double</span> <span class="identifier">sample</span> <span class="special">=</span> <span class="identifier">rng</span><span class="special">();</span>
    <span class="identifier">acc</span><span class="special">(</span><span class="identifier">sample</span><span class="special">);</span>
    <span class="identifier">acc2</span><span class="special">(</span><span class="identifier">sample</span><span class="special">);</span>
    <span class="identifier">acc_weighted</span><span class="special">(</span><span class="identifier">sample</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">1.</span><span class="special">);</span>
    <span class="identifier">acc_weighted2</span><span class="special">(</span><span class="identifier">sample</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">1.</span><span class="special">);</span>
<span class="special">}</span>

<span class="keyword">for</span> <span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special">&lt;</span> <span class="identifier">probs</span><span class="special">.</span><span class="identifier">size</span><span class="special">()</span> <span class="special">-</span> <span class="number">1</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
<span class="special">{</span>
    <span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span>
        <span class="identifier">quantile</span><span class="special">(</span><span class="identifier">acc</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.99025</span> <span class="special">+</span> <span class="identifier">i</span><span class="special">*</span><span class="number">0.001</span><span class="special">)</span>
      <span class="special">,</span> <span class="number">0.99025</span> <span class="special">+</span> <span class="identifier">i</span><span class="special">*</span><span class="number">0.001</span>
      <span class="special">,</span> <span class="identifier">epsilon</span>
    <span class="special">);</span>
    <span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span>
        <span class="identifier">quantile</span><span class="special">(</span><span class="identifier">acc2</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.99025</span> <span class="special">+</span> <span class="identifier">i</span><span class="special">*</span><span class="number">0.001</span><span class="special">)</span>
      <span class="special">,</span> <span class="number">0.99025</span> <span class="special">+</span> <span class="identifier">i</span><span class="special">*</span><span class="number">0.001</span>
      <span class="special">,</span> <span class="identifier">epsilon</span>
    <span class="special">);</span>
    <span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span>
        <span class="identifier">quantile</span><span class="special">(</span><span class="identifier">acc_weighted</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.99025</span> <span class="special">+</span> <span class="identifier">i</span><span class="special">*</span><span class="number">0.001</span><span class="special">)</span>
      <span class="special">,</span> <span class="number">0.99025</span> <span class="special">+</span> <span class="identifier">i</span><span class="special">*</span><span class="number">0.001</span>
      <span class="special">,</span> <span class="identifier">epsilon</span>
    <span class="special">);</span>
    <span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span>
        <span class="identifier">quantile</span><span class="special">(</span><span class="identifier">acc_weighted2</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.99025</span> <span class="special">+</span> <span class="identifier">i</span><span class="special">*</span><span class="number">0.001</span><span class="special">)</span>
      <span class="special">,</span> <span class="number">0.99025</span> <span class="special">+</span> <span class="identifier">i</span><span class="special">*</span><span class="number">0.001</span>
      <span class="special">,</span> <span class="identifier">epsilon</span>
    <span class="special">);</span>
<span class="special">}</span>
</pre>
<p>
          <span class="bold"><strong>See also</strong></span>
        </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
              <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/exten_1_3_2_6_3_9_1_1_12_1.html" title="Struct template extended_p_square_quantile_impl">extended_p_square_quantile_impl</a></code>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.extended_p_square" title="extended_p_square"><code class="literal">extended_p_square</code></a>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.weighted_extended_p_square" title="weighted_extended_p_square"><code class="literal">weighted_extended_p_square</code></a>
            </li>
</ul></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="accumulators.user_s_guide.the_statistical_accumulators_library.kurtosis"></a><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.kurtosis" title="kurtosis">kurtosis</a>
</h4></div></div></div>
<p>
          The kurtosis of a sample distribution is defined as the ratio of the 4th
          central moment and the square of the 2nd central moment (the variance)
          of the samples, minus 3. The term <code class="literal">-3</code> is added in order
          to ensure that the normal distribution has zero kurtosis. For more implementation
          details, see <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/kurtosis_impl.html" title="Struct template kurtosis_impl">kurtosis_impl</a></code>
        </p>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Result Type</span></dt>
<dd>
<p>
</p>
<pre class="programlisting"><span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">fdiv</span><span class="special">&lt;</span><em class="replaceable"><code>sample-type</code></em><span class="special">,</span> <em class="replaceable"><code>sample-type</code></em><span class="special">&gt;::</span><span class="identifier">result_type</span>
</pre>
<p>
              </p>
</dd>
<dt><span class="term">Depends On</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">mean</span></code> <br> <code class="computeroutput"><span class="identifier">moment</span><span class="special">&lt;</span><span class="number">2</span><span class="special">&gt;</span></code>
                <br> <code class="computeroutput"><span class="identifier">moment</span><span class="special">&lt;</span><span class="number">3</span><span class="special">&gt;</span></code>
                <br> <code class="computeroutput"><span class="identifier">moment</span><span class="special">&lt;</span><span class="number">4</span><span class="special">&gt;</span></code>
              </p></dd>
<dt><span class="term">Variants</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Initialization Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Accumulator Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Extractor Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Accumulator Complexity</span></dt>
<dd><p>
                O(1)
              </p></dd>
<dt><span class="term">Extractor Complexity</span></dt>
<dd><p>
                O(1)
              </p></dd>
</dl>
</div>
<p>
          <span class="bold"><strong>Header</strong></span>
        </p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><code class="computeroutput"><a class="link" href="reference.html#header.boost.accumulators.statistics.kurtosis_hpp" title="Header &lt;boost/accumulators/statistics/kurtosis.hpp&gt;">boost/accumulators/statistics/kurtosis.hpp</a></code><span class="special">&gt;</span>
</pre>
<p>
          <span class="bold"><strong>Example</strong></span>
        </p>
<pre class="programlisting"><span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">kurtosis</span> <span class="special">&gt;</span> <span class="special">&gt;</span> <span class="identifier">acc</span><span class="special">;</span>

<span class="identifier">acc</span><span class="special">(</span><span class="number">2</span><span class="special">);</span>
<span class="identifier">acc</span><span class="special">(</span><span class="number">7</span><span class="special">);</span>
<span class="identifier">acc</span><span class="special">(</span><span class="number">4</span><span class="special">);</span>
<span class="identifier">acc</span><span class="special">(</span><span class="number">9</span><span class="special">);</span>
<span class="identifier">acc</span><span class="special">(</span><span class="number">3</span><span class="special">);</span>

<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="identifier">mean</span><span class="special">(</span><span class="identifier">acc</span><span class="special">),</span> <span class="number">5</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="identifier">accumulators</span><span class="special">::</span><span class="identifier">moment</span><span class="special">&lt;</span><span class="number">2</span><span class="special">&gt;(</span><span class="identifier">acc</span><span class="special">),</span> <span class="number">159.</span><span class="special">/</span><span class="number">5.</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="identifier">accumulators</span><span class="special">::</span><span class="identifier">moment</span><span class="special">&lt;</span><span class="number">3</span><span class="special">&gt;(</span><span class="identifier">acc</span><span class="special">),</span> <span class="number">1171.</span><span class="special">/</span><span class="number">5.</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="identifier">accumulators</span><span class="special">::</span><span class="identifier">moment</span><span class="special">&lt;</span><span class="number">4</span><span class="special">&gt;(</span><span class="identifier">acc</span><span class="special">),</span> <span class="number">1863</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">kurtosis</span><span class="special">(</span><span class="identifier">acc</span><span class="special">),</span> <span class="special">-</span><span class="number">1.39965397924</span><span class="special">,</span> <span class="number">1e-6</span> <span class="special">);</span>
</pre>
<p>
          <span class="bold"><strong>See also</strong></span>
        </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
              <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/kurtosis_impl.html" title="Struct template kurtosis_impl">kurtosis_impl</a></code>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.mean" title="mean and variants"><code class="literal">mean</code></a>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.moment" title="moment"><code class="literal">moment</code></a>
            </li>
</ul></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="accumulators.user_s_guide.the_statistical_accumulators_library.max"></a><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.max" title="max">max</a>
</h4></div></div></div>
<p>
          Calculates the maximum value of all the samples.
        </p>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Result Type</span></dt>
<dd>
<p>
</p>
<pre class="programlisting"><em class="replaceable"><code>sample-type</code></em>
</pre>
<p>
              </p>
</dd>
<dt><span class="term">Depends On</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Variants</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Initialization Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Accumulator Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Extractor Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Accumulator Complexity</span></dt>
<dd><p>
                O(1)
              </p></dd>
<dt><span class="term">Extractor Complexity</span></dt>
<dd><p>
                O(1)
              </p></dd>
</dl>
</div>
<p>
          <span class="bold"><strong>Header</strong></span>
        </p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><code class="computeroutput"><a class="link" href="reference.html#header.boost.accumulators.statistics.max_hpp" title="Header &lt;boost/accumulators/statistics/max.hpp&gt;">boost/accumulators/statistics/max.hpp</a></code><span class="special">&gt;</span>
</pre>
<p>
          <span class="bold"><strong>Example</strong></span>
        </p>
<pre class="programlisting"><span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">max</span><span class="special">&gt;</span> <span class="special">&gt;</span> <span class="identifier">acc</span><span class="special">;</span>

<span class="identifier">acc</span><span class="special">(</span><span class="number">1</span><span class="special">);</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span><span class="number">1</span><span class="special">,</span> <span class="special">(</span><span class="identifier">max</span><span class="special">)(</span><span class="identifier">acc</span><span class="special">));</span>

<span class="identifier">acc</span><span class="special">(</span><span class="number">0</span><span class="special">);</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span><span class="number">1</span><span class="special">,</span> <span class="special">(</span><span class="identifier">max</span><span class="special">)(</span><span class="identifier">acc</span><span class="special">));</span>

<span class="identifier">acc</span><span class="special">(</span><span class="number">2</span><span class="special">);</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span><span class="number">2</span><span class="special">,</span> <span class="special">(</span><span class="identifier">max</span><span class="special">)(</span><span class="identifier">acc</span><span class="special">));</span>
</pre>
<p>
          <span class="bold"><strong>See also</strong></span>
        </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
              <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/max_impl.html" title="Struct template max_impl">max_impl</a></code>
            </li></ul></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="accumulators.user_s_guide.the_statistical_accumulators_library.mean"></a><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.mean" title="mean and variants">mean
        <span class="emphasis"><em>and variants</em></span></a>
</h4></div></div></div>
<p>
          Calculates the mean of samples, weights or variates. The calculation is
          either lazy (in the result extractor), or immediate (in the accumulator).
          The lazy implementation is the default. For more implementation details,
          see <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/mean_impl.html" title="Struct template mean_impl">mean_impl</a></code>
          or. <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/immediate_mean_impl.html" title="Struct template immediate_mean_impl">immediate_mean_impl</a></code>
        </p>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Result Type</span></dt>
<dd><p>
                For samples, <code class="computeroutput"><span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">fdiv</span><span class="special">&lt;</span><em class="replaceable"><code>sample-type</code></em><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">&gt;::</span><span class="identifier">result_type</span></code> <br> For weights,
                <code class="computeroutput"><span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">fdiv</span><span class="special">&lt;</span><em class="replaceable"><code>weight-type</code></em><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">&gt;::</span><span class="identifier">result_type</span></code>
                <br> For variates, <code class="computeroutput"><span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">fdiv</span><span class="special">&lt;</span><em class="replaceable"><code>variate-type</code></em><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">&gt;::</span><span class="identifier">result_type</span></code>
              </p></dd>
<dt><span class="term">Depends On</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">count</span></code> <br> The
                lazy mean of samples depends on <code class="computeroutput"><span class="identifier">sum</span></code>
                <br> The lazy mean of weights depends on <code class="computeroutput"><span class="identifier">sum_of_weights</span></code>
                <br> The lazy mean of variates depends on <code class="computeroutput"><span class="identifier">sum_of_variates</span><span class="special">&lt;&gt;</span></code>
              </p></dd>
<dt><span class="term">Variants</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">mean_of_weights</span></code>
                <br> <code class="computeroutput"><span class="identifier">mean_of_variates</span><span class="special">&lt;</span><em class="replaceable"><code>variate-type</code></em><span class="special">,</span> <em class="replaceable"><code>variate-tag</code></em><span class="special">&gt;</span></code> <br> <code class="computeroutput"><span class="identifier">immediate_mean</span></code>
                <br> <code class="computeroutput"><span class="identifier">immediate_mean_of_weights</span></code>
                <br> <code class="computeroutput"><span class="identifier">immediate_mean_of_variates</span><span class="special">&lt;</span><em class="replaceable"><code>variate-type</code></em><span class="special">,</span> <em class="replaceable"><code>variate-tag</code></em><span class="special">&gt;</span></code>
              </p></dd>
<dt><span class="term">Initialization Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Accumulator Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Extractor Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Accumulator Complexity</span></dt>
<dd><p>
                O(1)
              </p></dd>
<dt><span class="term">Extractor Complexity</span></dt>
<dd><p>
                O(1)
              </p></dd>
</dl>
</div>
<p>
          <span class="bold"><strong>Header</strong></span>
        </p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><code class="computeroutput"><a class="link" href="reference.html#header.boost.accumulators.statistics.mean_hpp" title="Header &lt;boost/accumulators/statistics/mean.hpp&gt;">boost/accumulators/statistics/mean.hpp</a></code><span class="special">&gt;</span>
</pre>
<p>
          <span class="bold"><strong>Example</strong></span>
        </p>
<pre class="programlisting"><span class="identifier">accumulator_set</span><span class="special">&lt;</span>
    <span class="keyword">int</span>
  <span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span>
        <span class="identifier">tag</span><span class="special">::</span><span class="identifier">mean</span>
      <span class="special">,</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">mean_of_weights</span>
      <span class="special">,</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">mean_of_variates</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">,</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">covariate1</span><span class="special">&gt;</span>
    <span class="special">&gt;</span>
  <span class="special">,</span> <span class="keyword">int</span>
<span class="special">&gt;</span> <span class="identifier">acc</span><span class="special">;</span>

<span class="identifier">acc</span><span class="special">(</span><span class="number">1</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">2</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="number">3</span><span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span><span class="number">1.</span><span class="special">,</span> <span class="identifier">mean</span><span class="special">(</span><span class="identifier">acc</span><span class="special">),</span> <span class="number">1e-5</span><span class="special">);</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span><span class="number">1u</span><span class="special">,</span> <span class="identifier">count</span><span class="special">(</span><span class="identifier">acc</span><span class="special">));</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span><span class="number">2</span><span class="special">,</span> <span class="identifier">sum</span><span class="special">(</span><span class="identifier">acc</span><span class="special">));</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span><span class="number">2.</span><span class="special">,</span> <span class="identifier">mean_of_weights</span><span class="special">(</span><span class="identifier">acc</span><span class="special">),</span> <span class="number">1e-5</span><span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span><span class="number">3.</span><span class="special">,</span> <span class="special">(</span><span class="identifier">accumulators</span><span class="special">::</span><span class="identifier">mean_of_variates</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">,</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">covariate1</span><span class="special">&gt;(</span><span class="identifier">acc</span><span class="special">)),</span> <span class="number">1e-5</span><span class="special">);</span>

<span class="identifier">acc</span><span class="special">(</span><span class="number">0</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">4</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="number">4</span><span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span><span class="number">0.33333333333333333</span><span class="special">,</span> <span class="identifier">mean</span><span class="special">(</span><span class="identifier">acc</span><span class="special">),</span> <span class="number">1e-5</span><span class="special">);</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span><span class="number">2u</span><span class="special">,</span> <span class="identifier">count</span><span class="special">(</span><span class="identifier">acc</span><span class="special">));</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span><span class="number">2</span><span class="special">,</span> <span class="identifier">sum</span><span class="special">(</span><span class="identifier">acc</span><span class="special">));</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span><span class="number">3.</span><span class="special">,</span> <span class="identifier">mean_of_weights</span><span class="special">(</span><span class="identifier">acc</span><span class="special">),</span> <span class="number">1e-5</span><span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span><span class="number">3.5</span><span class="special">,</span> <span class="special">(</span><span class="identifier">accumulators</span><span class="special">::</span><span class="identifier">mean_of_variates</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">,</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">covariate1</span><span class="special">&gt;(</span><span class="identifier">acc</span><span class="special">)),</span> <span class="number">1e-5</span><span class="special">);</span>

<span class="identifier">acc</span><span class="special">(</span><span class="number">2</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">9</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="number">8</span><span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span><span class="number">1.33333333333333333</span><span class="special">,</span> <span class="identifier">mean</span><span class="special">(</span><span class="identifier">acc</span><span class="special">),</span> <span class="number">1e-5</span><span class="special">);</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span><span class="number">3u</span><span class="special">,</span> <span class="identifier">count</span><span class="special">(</span><span class="identifier">acc</span><span class="special">));</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span><span class="number">20</span><span class="special">,</span> <span class="identifier">sum</span><span class="special">(</span><span class="identifier">acc</span><span class="special">));</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span><span class="number">5.</span><span class="special">,</span> <span class="identifier">mean_of_weights</span><span class="special">(</span><span class="identifier">acc</span><span class="special">),</span> <span class="number">1e-5</span><span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span><span class="number">5.</span><span class="special">,</span> <span class="special">(</span><span class="identifier">accumulators</span><span class="special">::</span><span class="identifier">mean_of_variates</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">,</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">covariate1</span><span class="special">&gt;(</span><span class="identifier">acc</span><span class="special">)),</span> <span class="number">1e-5</span><span class="special">);</span>

<span class="identifier">accumulator_set</span><span class="special">&lt;</span>
    <span class="keyword">int</span>
  <span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span>
        <span class="identifier">tag</span><span class="special">::</span><span class="identifier">mean</span><span class="special">(</span><span class="identifier">immediate</span><span class="special">)</span>
      <span class="special">,</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">mean_of_weights</span><span class="special">(</span><span class="identifier">immediate</span><span class="special">)</span>
      <span class="special">,</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">mean_of_variates</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">,</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">covariate1</span><span class="special">&gt;(</span><span class="identifier">immediate</span><span class="special">)</span>
    <span class="special">&gt;</span>
  <span class="special">,</span> <span class="keyword">int</span>
<span class="special">&gt;</span> <span class="identifier">acc2</span><span class="special">;</span>

<span class="identifier">acc2</span><span class="special">(</span><span class="number">1</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">2</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="number">3</span><span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span><span class="number">1.</span><span class="special">,</span> <span class="identifier">mean</span><span class="special">(</span><span class="identifier">acc2</span><span class="special">),</span> <span class="number">1e-5</span><span class="special">);</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span><span class="number">1u</span><span class="special">,</span> <span class="identifier">count</span><span class="special">(</span><span class="identifier">acc2</span><span class="special">));</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span><span class="number">2.</span><span class="special">,</span> <span class="identifier">mean_of_weights</span><span class="special">(</span><span class="identifier">acc2</span><span class="special">),</span> <span class="number">1e-5</span><span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span><span class="number">3.</span><span class="special">,</span> <span class="special">(</span><span class="identifier">accumulators</span><span class="special">::</span><span class="identifier">mean_of_variates</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">,</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">covariate1</span><span class="special">&gt;(</span><span class="identifier">acc2</span><span class="special">)),</span> <span class="number">1e-5</span><span class="special">);</span>

<span class="identifier">acc2</span><span class="special">(</span><span class="number">0</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">4</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="number">4</span><span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span><span class="number">0.33333333333333333</span><span class="special">,</span> <span class="identifier">mean</span><span class="special">(</span><span class="identifier">acc2</span><span class="special">),</span> <span class="number">1e-5</span><span class="special">);</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span><span class="number">2u</span><span class="special">,</span> <span class="identifier">count</span><span class="special">(</span><span class="identifier">acc2</span><span class="special">));</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span><span class="number">3.</span><span class="special">,</span> <span class="identifier">mean_of_weights</span><span class="special">(</span><span class="identifier">acc2</span><span class="special">),</span> <span class="number">1e-5</span><span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span><span class="number">3.5</span><span class="special">,</span> <span class="special">(</span><span class="identifier">accumulators</span><span class="special">::</span><span class="identifier">mean_of_variates</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">,</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">covariate1</span><span class="special">&gt;(</span><span class="identifier">acc2</span><span class="special">)),</span> <span class="number">1e-5</span><span class="special">);</span>

<span class="identifier">acc2</span><span class="special">(</span><span class="number">2</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">9</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="number">8</span><span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span><span class="number">1.33333333333333333</span><span class="special">,</span> <span class="identifier">mean</span><span class="special">(</span><span class="identifier">acc2</span><span class="special">),</span> <span class="number">1e-5</span><span class="special">);</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span><span class="number">3u</span><span class="special">,</span> <span class="identifier">count</span><span class="special">(</span><span class="identifier">acc2</span><span class="special">));</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span><span class="number">5.</span><span class="special">,</span> <span class="identifier">mean_of_weights</span><span class="special">(</span><span class="identifier">acc2</span><span class="special">),</span> <span class="number">1e-5</span><span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span><span class="number">5.</span><span class="special">,</span> <span class="special">(</span><span class="identifier">accumulators</span><span class="special">::</span><span class="identifier">mean_of_variates</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">,</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">covariate1</span><span class="special">&gt;(</span><span class="identifier">acc2</span><span class="special">)),</span> <span class="number">1e-5</span><span class="special">);</span>
</pre>
<p>
          <span class="bold"><strong>See also</strong></span>
        </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
              <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/mean_impl.html" title="Struct template mean_impl">mean_impl</a></code>
            </li>
<li class="listitem">
              <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/immediate_mean_impl.html" title="Struct template immediate_mean_impl">immediate_mean_impl</a></code>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.count" title="count"><code class="literal">count</code></a>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.sum" title="sum and variants"><code class="literal">sum</code></a>
            </li>
</ul></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="accumulators.user_s_guide.the_statistical_accumulators_library.median"></a><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.median" title="median and variants">median
        <span class="emphasis"><em>and variants</em></span></a>
</h4></div></div></div>
<p>
          Median estimation based on the <code class="literal">P^2</code> quantile estimator,
          the density estimator, or the <code class="literal">P^2</code> cumulative distribution
          estimator. For more implementation details, see <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/median_impl.html" title="Struct template median_impl">median_impl</a></code>,
          <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/with_density_median_impl.html" title="Struct template with_density_median_impl">with_density_median_impl</a></code>,
          and <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/with_1_3_2_6_3_13_1_1_13_3.html" title="Struct template with_p_square_cumulative_distribution_median_impl">with_p_square_cumulative_distribution_median_impl</a></code>.
        </p>
<p>
          The three median accumulators all satisfy the <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">median</span></code>
          feature, and can all be extracted with the <code class="computeroutput"><span class="identifier">median</span><span class="special">()</span></code> extractor.
        </p>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Result Type</span></dt>
<dd>
<p>
</p>
<pre class="programlisting"><span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">fdiv</span><span class="special">&lt;</span><em class="replaceable"><code>sample-type</code></em><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">&gt;::</span><span class="identifier">result_type</span>
</pre>
<p>
              </p>
</dd>
<dt><span class="term">Depends On</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">median</span></code> depends on
                <code class="computeroutput"><span class="identifier">p_square_quantile_for_median</span></code>
                <br> <code class="computeroutput"><span class="identifier">with_density_median</span></code>
                depends on <code class="computeroutput"><span class="identifier">count</span></code>
                and <code class="computeroutput"><span class="identifier">density</span></code> <br>
                <code class="computeroutput"><span class="identifier">with_p_square_cumulative_distribution_median</span></code>
                depends on <code class="computeroutput"><span class="identifier">p_square_cumulative_distribution</span></code>
              </p></dd>
<dt><span class="term">Variants</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">with_density_median</span></code>
                <br> <code class="computeroutput"><span class="identifier">with_p_square_cumulative_distribution_median</span></code>
              </p></dd>
<dt><span class="term">Initialization Parameters</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">with_density_median</span></code>
                requires <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">density</span><span class="special">::</span><span class="identifier">cache_size</span></code> and <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">density</span><span class="special">::</span><span class="identifier">num_bins</span></code>
                <br> <code class="computeroutput"><span class="identifier">with_p_square_cumulative_distribution_median</span></code>
                requires <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">p_square_cumulative_distribution</span><span class="special">::</span><span class="identifier">num_cells</span></code>
              </p></dd>
<dt><span class="term">Accumulator Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Extractor Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Accumulator Complexity</span></dt>
<dd><p>
                TODO
              </p></dd>
<dt><span class="term">Extractor Complexity</span></dt>
<dd><p>
                TODO
              </p></dd>
</dl>
</div>
<p>
          <span class="bold"><strong>Header</strong></span>
        </p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><code class="computeroutput"><a class="link" href="reference.html#header.boost.accumulators.statistics.median_hpp" title="Header &lt;boost/accumulators/statistics/median.hpp&gt;">boost/accumulators/statistics/median.hpp</a></code><span class="special">&gt;</span>
</pre>
<p>
          <span class="bold"><strong>Example</strong></span>
        </p>
<pre class="programlisting"><span class="comment">// two random number generators</span>
<span class="keyword">double</span> <span class="identifier">mu</span> <span class="special">=</span> <span class="number">1.</span><span class="special">;</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">lagged_fibonacci607</span> <span class="identifier">rng</span><span class="special">;</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">normal_distribution</span><span class="special">&lt;&gt;</span> <span class="identifier">mean_sigma</span><span class="special">(</span><span class="identifier">mu</span><span class="special">,</span><span class="number">1</span><span class="special">);</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">variate_generator</span><span class="special">&lt;</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">lagged_fibonacci607</span><span class="special">&amp;,</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">normal_distribution</span><span class="special">&lt;&gt;</span> <span class="special">&gt;</span>
    <span class="identifier">normal</span><span class="special">(</span><span class="identifier">rng</span><span class="special">,</span> <span class="identifier">mean_sigma</span><span class="special">);</span>

<span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">median</span><span class="special">(</span><span class="identifier">with_p_square_quantile</span><span class="special">)</span> <span class="special">&gt;</span> <span class="special">&gt;</span> <span class="identifier">acc</span><span class="special">;</span>
<span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">median</span><span class="special">(</span><span class="identifier">with_density</span><span class="special">)</span> <span class="special">&gt;</span> <span class="special">&gt;</span>
    <span class="identifier">acc_dens</span><span class="special">(</span> <span class="identifier">density_cache_size</span> <span class="special">=</span> <span class="number">10000</span><span class="special">,</span> <span class="identifier">density_num_bins</span> <span class="special">=</span> <span class="number">1000</span> <span class="special">);</span>
<span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">median</span><span class="special">(</span><span class="identifier">with_p_square_cumulative_distribution</span><span class="special">)</span> <span class="special">&gt;</span> <span class="special">&gt;</span>
    <span class="identifier">acc_cdist</span><span class="special">(</span> <span class="identifier">p_square_cumulative_distribution_num_cells</span> <span class="special">=</span> <span class="number">100</span> <span class="special">);</span>

<span class="keyword">for</span> <span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">i</span><span class="special">=</span><span class="number">0</span><span class="special">;</span> <span class="identifier">i</span><span class="special">&lt;</span><span class="number">100000</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
<span class="special">{</span>
    <span class="keyword">double</span> <span class="identifier">sample</span> <span class="special">=</span> <span class="identifier">normal</span><span class="special">();</span>
    <span class="identifier">acc</span><span class="special">(</span><span class="identifier">sample</span><span class="special">);</span>
    <span class="identifier">acc_dens</span><span class="special">(</span><span class="identifier">sample</span><span class="special">);</span>
    <span class="identifier">acc_cdist</span><span class="special">(</span><span class="identifier">sample</span><span class="special">);</span>
<span class="special">}</span>

<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span><span class="number">1.</span><span class="special">,</span> <span class="identifier">median</span><span class="special">(</span><span class="identifier">acc</span><span class="special">),</span> <span class="number">1.</span><span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span><span class="number">1.</span><span class="special">,</span> <span class="identifier">median</span><span class="special">(</span><span class="identifier">acc_dens</span><span class="special">),</span> <span class="number">1.</span><span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span><span class="number">1.</span><span class="special">,</span> <span class="identifier">median</span><span class="special">(</span><span class="identifier">acc_cdist</span><span class="special">),</span> <span class="number">3.</span><span class="special">);</span>
</pre>
<p>
          <span class="bold"><strong>See also</strong></span>
        </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
              <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/median_impl.html" title="Struct template median_impl">median_impl</a></code>
            </li>
<li class="listitem">
              <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/with_density_median_impl.html" title="Struct template with_density_median_impl">with_density_median_impl</a></code>
            </li>
<li class="listitem">
              <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/with_1_3_2_6_3_13_1_1_13_3.html" title="Struct template with_p_square_cumulative_distribution_median_impl">with_p_square_cumulative_distribution_median_impl</a></code>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.count" title="count"><code class="literal">count</code></a>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.p_square_quantile" title="p_square_quantile and variants"><code class="literal">p_square_quantile</code></a>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.p_square_cumulative_distribution" title="p_square_cumulative_distribution"><code class="literal">p_square_cumulative_distribution</code></a>
            </li>
</ul></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="accumulators.user_s_guide.the_statistical_accumulators_library.min"></a><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.min" title="min">min</a>
</h4></div></div></div>
<p>
          Calculates the minimum value of all the samples.
        </p>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Result Type</span></dt>
<dd>
<p>
</p>
<pre class="programlisting"><em class="replaceable"><code>sample-type</code></em>
</pre>
<p>
              </p>
</dd>
<dt><span class="term">Depends On</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Variants</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Initialization Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Accumulator Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Extractor Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Accumulator Complexity</span></dt>
<dd><p>
                O(1)
              </p></dd>
<dt><span class="term">Extractor Complexity</span></dt>
<dd><p>
                O(1)
              </p></dd>
</dl>
</div>
<p>
          <span class="bold"><strong>Header</strong></span>
        </p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><code class="computeroutput"><a class="link" href="reference.html#header.boost.accumulators.statistics.min_hpp" title="Header &lt;boost/accumulators/statistics/min.hpp&gt;">boost/accumulators/statistics/min.hpp</a></code><span class="special">&gt;</span>
</pre>
<p>
          <span class="bold"><strong>Example</strong></span>
        </p>
<pre class="programlisting"><span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">min</span><span class="special">&gt;</span> <span class="special">&gt;</span> <span class="identifier">acc</span><span class="special">;</span>

<span class="identifier">acc</span><span class="special">(</span><span class="number">1</span><span class="special">);</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span><span class="number">1</span><span class="special">,</span> <span class="special">(</span><span class="identifier">min</span><span class="special">)(</span><span class="identifier">acc</span><span class="special">));</span>

<span class="identifier">acc</span><span class="special">(</span><span class="number">0</span><span class="special">);</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span><span class="number">0</span><span class="special">,</span> <span class="special">(</span><span class="identifier">min</span><span class="special">)(</span><span class="identifier">acc</span><span class="special">));</span>

<span class="identifier">acc</span><span class="special">(</span><span class="number">2</span><span class="special">);</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span><span class="number">0</span><span class="special">,</span> <span class="special">(</span><span class="identifier">min</span><span class="special">)(</span><span class="identifier">acc</span><span class="special">));</span>
</pre>
<p>
          <span class="bold"><strong>See also</strong></span>
        </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
              <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/min_impl.html" title="Struct template min_impl">min_impl</a></code>
            </li></ul></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="accumulators.user_s_guide.the_statistical_accumulators_library.moment"></a><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.moment" title="moment">moment</a>
</h4></div></div></div>
<p>
          Calculates the N-th moment of the samples, which is defined as the sum
          of the N-th power of the samples over the count of samples.
        </p>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Result Type</span></dt>
<dd>
<p>
</p>
<pre class="programlisting"><span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">fdiv</span><span class="special">&lt;</span><em class="replaceable"><code>sample-type</code></em><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">&gt;::</span><span class="identifier">result_type</span>
</pre>
<p>
              </p>
</dd>
<dt><span class="term">Depends On</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">count</span></code>
              </p></dd>
<dt><span class="term">Variants</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Initialization Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Accumulator Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Extractor Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Accumulator Complexity</span></dt>
<dd><p>
                O(1)
              </p></dd>
<dt><span class="term">Extractor Complexity</span></dt>
<dd><p>
                O(1)
              </p></dd>
</dl>
</div>
<p>
          <span class="bold"><strong>Header</strong></span>
        </p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><code class="computeroutput"><a class="link" href="reference.html#header.boost.accumulators.statistics.moment_hpp" title="Header &lt;boost/accumulators/statistics/moment.hpp&gt;">boost/accumulators/statistics/moment.hpp</a></code><span class="special">&gt;</span>
</pre>
<p>
          <span class="bold"><strong>Example</strong></span>
        </p>
<pre class="programlisting"><span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">moment</span><span class="special">&lt;</span><span class="number">2</span><span class="special">&gt;</span> <span class="special">&gt;</span> <span class="special">&gt;</span> <span class="identifier">acc1</span><span class="special">;</span>

<span class="identifier">acc1</span><span class="special">(</span><span class="number">2</span><span class="special">);</span> <span class="comment">//    4</span>
<span class="identifier">acc1</span><span class="special">(</span><span class="number">4</span><span class="special">);</span> <span class="comment">//   16</span>
<span class="identifier">acc1</span><span class="special">(</span><span class="number">5</span><span class="special">);</span> <span class="comment">// + 25</span>
         <span class="comment">// = 45 / 3 = 15</span>

<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span><span class="number">15.</span><span class="special">,</span> <span class="identifier">accumulators</span><span class="special">::</span><span class="identifier">moment</span><span class="special">&lt;</span><span class="number">2</span><span class="special">&gt;(</span><span class="identifier">acc1</span><span class="special">),</span> <span class="number">1e-5</span><span class="special">);</span>

<span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">moment</span><span class="special">&lt;</span><span class="number">5</span><span class="special">&gt;</span> <span class="special">&gt;</span> <span class="special">&gt;</span> <span class="identifier">acc2</span><span class="special">;</span>

<span class="identifier">acc2</span><span class="special">(</span><span class="number">2</span><span class="special">);</span> <span class="comment">//     32</span>
<span class="identifier">acc2</span><span class="special">(</span><span class="number">3</span><span class="special">);</span> <span class="comment">//    243</span>
<span class="identifier">acc2</span><span class="special">(</span><span class="number">4</span><span class="special">);</span> <span class="comment">//   1024</span>
<span class="identifier">acc2</span><span class="special">(</span><span class="number">5</span><span class="special">);</span> <span class="comment">// + 3125</span>
         <span class="comment">// = 4424 / 4 = 1106</span>

<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span><span class="number">1106.</span><span class="special">,</span> <span class="identifier">accumulators</span><span class="special">::</span><span class="identifier">moment</span><span class="special">&lt;</span><span class="number">5</span><span class="special">&gt;(</span><span class="identifier">acc2</span><span class="special">),</span> <span class="number">1e-5</span><span class="special">);</span>
</pre>
<p>
          <span class="bold"><strong>See also</strong></span>
        </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
              <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/moment_impl.html" title="Struct template moment_impl">moment_impl</a></code>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.count" title="count"><code class="literal">count</code></a>
            </li>
</ul></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="accumulators.user_s_guide.the_statistical_accumulators_library.p_square_cumulative_distribution"></a><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.p_square_cumulative_distribution" title="p_square_cumulative_distribution">p_square_cumulative_distribution</a>
</h4></div></div></div>
<p>
          Histogram calculation of the cumulative distribution with the <code class="literal">P^2</code>
          algorithm. For more implementation details, see <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/p_squ_1_3_2_6_3_16_1_1_4_1.html" title="Struct template p_square_cumulative_distribution_impl">p_square_cumulative_distribution_impl</a></code>
        </p>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Result Type</span></dt>
<dd>
<p>
</p>
<pre class="programlisting"><span class="identifier">iterator_range</span><span class="special">&lt;</span>
    <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span>
        <span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special">&lt;</span>
            <span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">fdiv</span><span class="special">&lt;</span><em class="replaceable"><code>sample-type</code></em><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">&gt;::</span><span class="identifier">result_type</span>
          <span class="special">,</span> <span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">fdiv</span><span class="special">&lt;</span><em class="replaceable"><code>sample-type</code></em><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">&gt;::</span><span class="identifier">result_type</span>
        <span class="special">&gt;</span>
    <span class="special">&gt;::</span><span class="identifier">iterator</span>
<span class="special">&gt;</span>
</pre>
<p>
              </p>
</dd>
<dt><span class="term">Depends On</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">count</span></code>
              </p></dd>
<dt><span class="term">Variants</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Initialization Parameters</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">p_square_cumulative_distribution</span><span class="special">::</span><span class="identifier">num_cells</span></code>
              </p></dd>
<dt><span class="term">Accumulator Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Extractor Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Accumulator Complexity</span></dt>
<dd><p>
                TODO
              </p></dd>
<dt><span class="term">Extractor Complexity</span></dt>
<dd><p>
                O(N) where N is <code class="computeroutput"><span class="identifier">num_cells</span></code>
              </p></dd>
</dl>
</div>
<p>
          <span class="bold"><strong>Header</strong></span>
        </p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><code class="computeroutput"><a class="link" href="reference.html#header.boost.accumulators.statistics.p_square_cumul_dist_hpp" title="Header &lt;boost/accumulators/statistics/p_square_cumul_dist.hpp&gt;">boost/accumulators/statistics/p_square_cumul_dist.hpp</a></code><span class="special">&gt;</span>
</pre>
<p>
          <span class="bold"><strong>Example</strong></span>
        </p>
<pre class="programlisting"><span class="comment">// tolerance in %</span>
<span class="keyword">double</span> <span class="identifier">epsilon</span> <span class="special">=</span> <span class="number">3</span><span class="special">;</span>

<span class="keyword">typedef</span> <span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">p_square_cumulative_distribution</span><span class="special">&gt;</span> <span class="special">&gt;</span> <span class="identifier">accumulator_t</span><span class="special">;</span>

<span class="identifier">accumulator_t</span> <span class="identifier">acc</span><span class="special">(</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">p_square_cumulative_distribution</span><span class="special">::</span><span class="identifier">num_cells</span> <span class="special">=</span> <span class="number">100</span><span class="special">);</span>

<span class="comment">// two random number generators</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">lagged_fibonacci607</span> <span class="identifier">rng</span><span class="special">;</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">normal_distribution</span><span class="special">&lt;&gt;</span> <span class="identifier">mean_sigma</span><span class="special">(</span><span class="number">0</span><span class="special">,</span><span class="number">1</span><span class="special">);</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">variate_generator</span><span class="special">&lt;</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">lagged_fibonacci607</span><span class="special">&amp;,</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">normal_distribution</span><span class="special">&lt;&gt;</span> <span class="special">&gt;</span> <span class="identifier">normal</span><span class="special">(</span><span class="identifier">rng</span><span class="special">,</span> <span class="identifier">mean_sigma</span><span class="special">);</span>

<span class="keyword">for</span> <span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">i</span><span class="special">=</span><span class="number">0</span><span class="special">;</span> <span class="identifier">i</span><span class="special">&lt;</span><span class="number">100000</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
<span class="special">{</span>
    <span class="identifier">acc</span><span class="special">(</span><span class="identifier">normal</span><span class="special">());</span>
<span class="special">}</span>

<span class="keyword">typedef</span> <span class="identifier">iterator_range</span><span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">,</span> <span class="keyword">double</span><span class="special">&gt;</span> <span class="special">&gt;::</span><span class="identifier">iterator</span> <span class="special">&gt;</span> <span class="identifier">histogram_type</span><span class="special">;</span>
<span class="identifier">histogram_type</span> <span class="identifier">histogram</span> <span class="special">=</span> <span class="identifier">p_square_cumulative_distribution</span><span class="special">(</span><span class="identifier">acc</span><span class="special">);</span>

<span class="keyword">for</span> <span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special">&lt;</span> <span class="identifier">histogram</span><span class="special">.</span><span class="identifier">size</span><span class="special">();</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
<span class="special">{</span>
    <span class="comment">// problem with small results: epsilon is relative (in percent), not absolute!</span>
    <span class="keyword">if</span> <span class="special">(</span> <span class="identifier">histogram</span><span class="special">[</span><span class="identifier">i</span><span class="special">].</span><span class="identifier">second</span> <span class="special">&gt;</span> <span class="number">0.001</span> <span class="special">)</span>
        <span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="number">0.5</span> <span class="special">*</span> <span class="special">(</span><span class="number">1.0</span> <span class="special">+</span> <span class="identifier">erf</span><span class="special">(</span> <span class="identifier">histogram</span><span class="special">[</span><span class="identifier">i</span><span class="special">].</span><span class="identifier">first</span> <span class="special">/</span> <span class="identifier">sqrt</span><span class="special">(</span><span class="number">2.0</span><span class="special">)</span> <span class="special">)),</span> <span class="identifier">histogram</span><span class="special">[</span><span class="identifier">i</span><span class="special">].</span><span class="identifier">second</span><span class="special">,</span> <span class="identifier">epsilon</span> <span class="special">);</span>
<span class="special">}</span>
</pre>
<p>
          <span class="bold"><strong>See also</strong></span>
        </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
              <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/p_squ_1_3_2_6_3_16_1_1_4_1.html" title="Struct template p_square_cumulative_distribution_impl">p_square_cumulative_distribution_impl</a></code>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.count" title="count"><code class="literal">count</code></a>
            </li>
</ul></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="accumulators.user_s_guide.the_statistical_accumulators_library.p_square_quantile"></a><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.p_square_quantile" title="p_square_quantile and variants">p_square_quantile
        <span class="emphasis"><em>and variants</em></span></a>
</h4></div></div></div>
<p>
          Single quantile estimation with the <code class="literal">P^2</code> algorithm. For
          more implementation details, see <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/p_square_quantile_impl.html" title="Struct template p_square_quantile_impl">p_square_quantile_impl</a></code>
        </p>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Result Type</span></dt>
<dd>
<p>
</p>
<pre class="programlisting"><span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">fdiv</span><span class="special">&lt;</span><em class="replaceable"><code>sample-type</code></em><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">&gt;::</span><span class="identifier">result_type</span>
</pre>
<p>
              </p>
</dd>
<dt><span class="term">Depends On</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">count</span></code>
              </p></dd>
<dt><span class="term">Variants</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">p_square_quantile_for_median</span></code>
              </p></dd>
<dt><span class="term">Initialization Parameters</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">quantile_probability</span></code>,
                which defaults to <code class="computeroutput"><span class="number">0.5</span></code>.
                (Note: for <code class="computeroutput"><span class="identifier">p_square_quantile_for_median</span></code>,
                the <code class="computeroutput"><span class="identifier">quantile_probability</span></code>
                parameter is ignored and is always <code class="computeroutput"><span class="number">0.5</span></code>.)
              </p></dd>
<dt><span class="term">Accumulator Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Extractor Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Accumulator Complexity</span></dt>
<dd><p>
                TODO
              </p></dd>
<dt><span class="term">Extractor Complexity</span></dt>
<dd><p>
                O(1)
              </p></dd>
</dl>
</div>
<p>
          <span class="bold"><strong>Header</strong></span>
        </p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><code class="computeroutput"><a class="link" href="reference.html#header.boost.accumulators.statistics.p_square_quantile_hpp" title="Header &lt;boost/accumulators/statistics/p_square_quantile.hpp&gt;">boost/accumulators/statistics/p_square_quantile.hpp</a></code><span class="special">&gt;</span>
</pre>
<p>
          <span class="bold"><strong>Example</strong></span>
        </p>
<pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">p_square_quantile</span><span class="special">&gt;</span> <span class="special">&gt;</span> <span class="identifier">accumulator_t</span><span class="special">;</span>

<span class="comment">// tolerance in %</span>
<span class="keyword">double</span> <span class="identifier">epsilon</span> <span class="special">=</span> <span class="number">1</span><span class="special">;</span>

<span class="comment">// a random number generator</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">lagged_fibonacci607</span> <span class="identifier">rng</span><span class="special">;</span>

<span class="identifier">accumulator_t</span> <span class="identifier">acc0</span><span class="special">(</span><span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.001</span><span class="special">);</span>
<span class="identifier">accumulator_t</span> <span class="identifier">acc1</span><span class="special">(</span><span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.01</span> <span class="special">);</span>
<span class="identifier">accumulator_t</span> <span class="identifier">acc2</span><span class="special">(</span><span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.1</span>  <span class="special">);</span>
<span class="identifier">accumulator_t</span> <span class="identifier">acc3</span><span class="special">(</span><span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.25</span> <span class="special">);</span>
<span class="identifier">accumulator_t</span> <span class="identifier">acc4</span><span class="special">(</span><span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.5</span>  <span class="special">);</span>
<span class="identifier">accumulator_t</span> <span class="identifier">acc5</span><span class="special">(</span><span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.75</span> <span class="special">);</span>
<span class="identifier">accumulator_t</span> <span class="identifier">acc6</span><span class="special">(</span><span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.9</span>  <span class="special">);</span>
<span class="identifier">accumulator_t</span> <span class="identifier">acc7</span><span class="special">(</span><span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.99</span> <span class="special">);</span>
<span class="identifier">accumulator_t</span> <span class="identifier">acc8</span><span class="special">(</span><span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.999</span><span class="special">);</span>

<span class="keyword">for</span> <span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span><span class="special">=</span><span class="number">0</span><span class="special">;</span> <span class="identifier">i</span><span class="special">&lt;</span><span class="number">100000</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
<span class="special">{</span>
    <span class="keyword">double</span> <span class="identifier">sample</span> <span class="special">=</span> <span class="identifier">rng</span><span class="special">();</span>
    <span class="identifier">acc0</span><span class="special">(</span><span class="identifier">sample</span><span class="special">);</span>
    <span class="identifier">acc1</span><span class="special">(</span><span class="identifier">sample</span><span class="special">);</span>
    <span class="identifier">acc2</span><span class="special">(</span><span class="identifier">sample</span><span class="special">);</span>
    <span class="identifier">acc3</span><span class="special">(</span><span class="identifier">sample</span><span class="special">);</span>
    <span class="identifier">acc4</span><span class="special">(</span><span class="identifier">sample</span><span class="special">);</span>
    <span class="identifier">acc5</span><span class="special">(</span><span class="identifier">sample</span><span class="special">);</span>
    <span class="identifier">acc6</span><span class="special">(</span><span class="identifier">sample</span><span class="special">);</span>
    <span class="identifier">acc7</span><span class="special">(</span><span class="identifier">sample</span><span class="special">);</span>
    <span class="identifier">acc8</span><span class="special">(</span><span class="identifier">sample</span><span class="special">);</span>
<span class="special">}</span>

<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">p_square_quantile</span><span class="special">(</span><span class="identifier">acc0</span><span class="special">),</span> <span class="number">0.001</span><span class="special">,</span> <span class="number">15</span><span class="special">*</span><span class="identifier">epsilon</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">p_square_quantile</span><span class="special">(</span><span class="identifier">acc1</span><span class="special">),</span> <span class="number">0.01</span> <span class="special">,</span> <span class="number">5</span><span class="special">*</span><span class="identifier">epsilon</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">p_square_quantile</span><span class="special">(</span><span class="identifier">acc2</span><span class="special">),</span> <span class="number">0.1</span>  <span class="special">,</span> <span class="identifier">epsilon</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">p_square_quantile</span><span class="special">(</span><span class="identifier">acc3</span><span class="special">),</span> <span class="number">0.25</span> <span class="special">,</span> <span class="identifier">epsilon</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">p_square_quantile</span><span class="special">(</span><span class="identifier">acc4</span><span class="special">),</span> <span class="number">0.5</span>  <span class="special">,</span> <span class="identifier">epsilon</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">p_square_quantile</span><span class="special">(</span><span class="identifier">acc5</span><span class="special">),</span> <span class="number">0.75</span> <span class="special">,</span> <span class="identifier">epsilon</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">p_square_quantile</span><span class="special">(</span><span class="identifier">acc6</span><span class="special">),</span> <span class="number">0.9</span>  <span class="special">,</span> <span class="identifier">epsilon</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">p_square_quantile</span><span class="special">(</span><span class="identifier">acc7</span><span class="special">),</span> <span class="number">0.99</span> <span class="special">,</span> <span class="identifier">epsilon</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">p_square_quantile</span><span class="special">(</span><span class="identifier">acc8</span><span class="special">),</span> <span class="number">0.999</span><span class="special">,</span> <span class="identifier">epsilon</span> <span class="special">);</span>
</pre>
<p>
          <span class="bold"><strong>See also</strong></span>
        </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
              <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/p_square_quantile_impl.html" title="Struct template p_square_quantile_impl">p_square_quantile_impl</a></code>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.count" title="count"><code class="literal">count</code></a>
            </li>
</ul></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="accumulators.user_s_guide.the_statistical_accumulators_library.peaks_over_threshold"></a><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.peaks_over_threshold" title="peaks_over_threshold and variants">peaks_over_threshold
        <span class="emphasis"><em>and variants</em></span></a>
</h4></div></div></div>
<p>
          Peaks Over Threshold method for quantile and tail mean estimation. For
          implementation details, see <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/peaks_over_threshold_impl.html" title="Struct template peaks_over_threshold_impl">peaks_over_threshold_impl</a></code>
          and <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/peak_1_3_2_6_3_19_1_1_10_2.html" title="Struct template peaks_over_threshold_prob_impl">peaks_over_threshold_prob_impl</a></code>.
        </p>
<p>
          Both <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">peaks_over_threshold</span></code> and <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">peaks_over_threshold_prob</span><span class="special">&lt;&gt;</span></code>
          satisfy the <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">abstract_peaks_over_threshold</span></code> feature,
          and can be extracted with the <code class="computeroutput"><span class="identifier">peaks_over_threshold</span><span class="special">()</span></code> extractor. The result is a 3-tuple representing
          the fit parameters <code class="computeroutput"><span class="identifier">u_bar</span></code>,
          <code class="computeroutput"><span class="identifier">beta_bar</span></code> and <code class="computeroutput"><span class="identifier">xi_hat</span></code>.
        </p>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Result Type</span></dt>
<dd>
<p>
</p>
<pre class="programlisting"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">tuple</span><span class="special">&lt;</span>
    <span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">fdiv</span><span class="special">&lt;</span><em class="replaceable"><code>sample-type</code></em><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">&gt;::</span><span class="identifier">result_type</span> <span class="comment">// u_bar</span>
  <span class="special">,</span> <span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">fdiv</span><span class="special">&lt;</span><em class="replaceable"><code>sample-type</code></em><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">&gt;::</span><span class="identifier">result_type</span> <span class="comment">// beta_bar</span>
  <span class="special">,</span> <span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">fdiv</span><span class="special">&lt;</span><em class="replaceable"><code>sample-type</code></em><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">&gt;::</span><span class="identifier">result_type</span> <span class="comment">// xi_hat</span>
<span class="special">&gt;</span>
</pre>
<p>
              </p>
</dd>
<dt><span class="term">Depends On</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">count</span></code> <br> In addition,
                <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">peaks_over_threshold_prob</span><span class="special">&lt;&gt;</span></code>
                depends on <code class="computeroutput"><span class="identifier">tail</span><span class="special">&lt;</span><em class="replaceable"><code>left-or-right</code></em><span class="special">&gt;</span></code>
              </p></dd>
<dt><span class="term">Variants</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">peaks_over_threshold_prob</span><span class="special">&lt;</span><em class="replaceable"><code>left-or-right</code></em><span class="special">&gt;</span></code>
              </p></dd>
<dt><span class="term">Initialization Parameters</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">peaks_over_threshold</span><span class="special">::</span><span class="identifier">threshold_value</span></code> <br> <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">peaks_over_threshold_prob</span><span class="special">::</span><span class="identifier">threshold_probability</span></code> <br> <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">tail</span><span class="special">&lt;</span><em class="replaceable"><code>left-or-right</code></em><span class="special">&gt;::</span><span class="identifier">cache_size</span></code>
              </p></dd>
<dt><span class="term">Accumulator Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Extractor Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Accumulator Complexity</span></dt>
<dd><p>
                TODO
              </p></dd>
<dt><span class="term">Extractor Complexity</span></dt>
<dd><p>
                TODO
              </p></dd>
</dl>
</div>
<p>
          <span class="bold"><strong>Header</strong></span>
        </p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><code class="computeroutput"><a class="link" href="reference.html#header.boost.accumulators.statistics.peaks_over_threshold_hpp" title="Header &lt;boost/accumulators/statistics/peaks_over_threshold.hpp&gt;">boost/accumulators/statistics/peaks_over_threshold.hpp</a></code><span class="special">&gt;</span>
</pre>
<p>
          <span class="bold"><strong>Example</strong></span>
        </p>
<p>
          See example for <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.pot_quantile" title="pot_quantile and variants"><code class="literal">pot_quantile</code></a>.
        </p>
<p>
          <span class="bold"><strong>See also</strong></span>
        </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
              <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/peaks_over_threshold_impl.html" title="Struct template peaks_over_threshold_impl">peaks_over_threshold_impl</a></code>
            </li>
<li class="listitem">
              <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/peak_1_3_2_6_3_19_1_1_10_2.html" title="Struct template peaks_over_threshold_prob_impl">peaks_over_threshold_prob_impl</a></code>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.count" title="count"><code class="literal">count</code></a>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.tail" title="tail"><code class="literal">tail</code></a>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.pot_quantile" title="pot_quantile and variants"><code class="literal">pot_quantile</code></a>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.pot_tail_mean" title="pot_tail_mean"><code class="literal">pot_tail_mean</code></a>
            </li>
</ul></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="accumulators.user_s_guide.the_statistical_accumulators_library.pot_quantile"></a><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.pot_quantile" title="pot_quantile and variants">pot_quantile
        <span class="emphasis"><em>and variants</em></span></a>
</h4></div></div></div>
<p>
          Quantile estimation based on Peaks over Threshold method (for both left
          and right tails). For implementation details, see <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/pot_quantile_impl.html" title="Struct template pot_quantile_impl">pot_quantile_impl</a></code>.
        </p>
<p>
          Both <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">pot_quantile</span><span class="special">&lt;</span><em class="replaceable"><code>left-or-right</code></em><span class="special">&gt;</span></code> and <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">pot_quantile_prob</span><span class="special">&lt;</span><em class="replaceable"><code>left-or-right</code></em><span class="special">&gt;</span></code>
          satisfy the <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">quantile</span></code> feature and can be extracted
          using the <code class="computeroutput"><span class="identifier">quantile</span><span class="special">()</span></code>
          extractor.
        </p>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Result Type</span></dt>
<dd>
<p>
</p>
<pre class="programlisting"><span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">fdiv</span><span class="special">&lt;</span><em class="replaceable"><code>sample-type</code></em><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">&gt;::</span><span class="identifier">result_type</span>
</pre>
<p>
              </p>
</dd>
<dt><span class="term">Depends On</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">pot_quantile</span><span class="special">&lt;</span><em class="replaceable"><code>left-or-right</code></em><span class="special">&gt;</span></code> depends on <code class="computeroutput"><span class="identifier">peaks_over_threshold</span><span class="special">&lt;</span><em class="replaceable"><code>left-or-right</code></em><span class="special">&gt;</span></code>
                <br> <code class="computeroutput"><span class="identifier">pot_quantile_prob</span><span class="special">&lt;</span><em class="replaceable"><code>left-or-right</code></em><span class="special">&gt;</span></code>
                depends on <code class="computeroutput"><span class="identifier">peaks_over_threshold_prob</span><span class="special">&lt;</span><em class="replaceable"><code>left-or-right</code></em><span class="special">&gt;</span></code>
              </p></dd>
<dt><span class="term">Variants</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">pot_quantile_prob</span><span class="special">&lt;</span><em class="replaceable"><code>left-or-right</code></em><span class="special">&gt;</span></code>
              </p></dd>
<dt><span class="term">Initialization Parameters</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">peaks_over_threshold</span><span class="special">::</span><span class="identifier">threshold_value</span></code> <br> <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">peaks_over_threshold_prob</span><span class="special">::</span><span class="identifier">threshold_probability</span></code> <br> <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">tail</span><span class="special">&lt;</span><em class="replaceable"><code>left-or-right</code></em><span class="special">&gt;::</span><span class="identifier">cache_size</span></code>
              </p></dd>
<dt><span class="term">Accumulator Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Extractor Parameters</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">quantile_probability</span></code>
              </p></dd>
<dt><span class="term">Accumulator Complexity</span></dt>
<dd><p>
                TODO
              </p></dd>
<dt><span class="term">Extractor Complexity</span></dt>
<dd><p>
                TODO
              </p></dd>
</dl>
</div>
<p>
          <span class="bold"><strong>Header</strong></span>
        </p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><code class="computeroutput"><a class="link" href="reference.html#header.boost.accumulators.statistics.pot_quantile_hpp" title="Header &lt;boost/accumulators/statistics/pot_quantile.hpp&gt;">boost/accumulators/statistics/pot_quantile.hpp</a></code><span class="special">&gt;</span>
</pre>
<p>
          <span class="bold"><strong>Example</strong></span>
        </p>
<pre class="programlisting"><span class="comment">// tolerance in %</span>
<span class="keyword">double</span> <span class="identifier">epsilon</span> <span class="special">=</span> <span class="number">1.</span><span class="special">;</span>

<span class="keyword">double</span> <span class="identifier">alpha</span> <span class="special">=</span> <span class="number">0.999</span><span class="special">;</span>
<span class="keyword">double</span> <span class="identifier">threshold_probability</span> <span class="special">=</span> <span class="number">0.99</span><span class="special">;</span>
<span class="keyword">double</span> <span class="identifier">threshold</span> <span class="special">=</span> <span class="number">3.</span><span class="special">;</span>

<span class="comment">// two random number generators</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">lagged_fibonacci607</span> <span class="identifier">rng</span><span class="special">;</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">normal_distribution</span><span class="special">&lt;&gt;</span> <span class="identifier">mean_sigma</span><span class="special">(</span><span class="number">0</span><span class="special">,</span><span class="number">1</span><span class="special">);</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">exponential_distribution</span><span class="special">&lt;&gt;</span> <span class="identifier">lambda</span><span class="special">(</span><span class="number">1</span><span class="special">);</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">variate_generator</span><span class="special">&lt;</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">lagged_fibonacci607</span><span class="special">&amp;,</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">normal_distribution</span><span class="special">&lt;&gt;</span> <span class="special">&gt;</span> <span class="identifier">normal</span><span class="special">(</span><span class="identifier">rng</span><span class="special">,</span> <span class="identifier">mean_sigma</span><span class="special">);</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">variate_generator</span><span class="special">&lt;</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">lagged_fibonacci607</span><span class="special">&amp;,</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">exponential_distribution</span><span class="special">&lt;&gt;</span> <span class="special">&gt;</span> <span class="identifier">exponential</span><span class="special">(</span><span class="identifier">rng</span><span class="special">,</span> <span class="identifier">lambda</span><span class="special">);</span>

<span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">pot_quantile</span><span class="special">&lt;</span><span class="identifier">right</span><span class="special">&gt;(</span><span class="identifier">with_threshold_value</span><span class="special">)&gt;</span> <span class="special">&gt;</span> <span class="identifier">acc1</span><span class="special">(</span>
    <span class="identifier">tag</span><span class="special">::</span><span class="identifier">peaks_over_threshold</span><span class="special">::</span><span class="identifier">threshold_value</span> <span class="special">=</span> <span class="identifier">threshold</span>
<span class="special">);</span>
<span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">pot_quantile</span><span class="special">&lt;</span><span class="identifier">right</span><span class="special">&gt;(</span><span class="identifier">with_threshold_probability</span><span class="special">)&gt;</span> <span class="special">&gt;</span> <span class="identifier">acc2</span><span class="special">(</span>
    <span class="identifier">tag</span><span class="special">::</span><span class="identifier">tail</span><span class="special">&lt;</span><span class="identifier">right</span><span class="special">&gt;::</span><span class="identifier">cache_size</span> <span class="special">=</span> <span class="number">2000</span>
  <span class="special">,</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">peaks_over_threshold_prob</span><span class="special">::</span><span class="identifier">threshold_probability</span> <span class="special">=</span> <span class="identifier">threshold_probability</span>
<span class="special">);</span>

<span class="identifier">threshold_probability</span> <span class="special">=</span> <span class="number">0.995</span><span class="special">;</span>
<span class="identifier">threshold</span> <span class="special">=</span> <span class="number">5.</span><span class="special">;</span>

<span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">pot_quantile</span><span class="special">&lt;</span><span class="identifier">right</span><span class="special">&gt;(</span><span class="identifier">with_threshold_value</span><span class="special">)&gt;</span> <span class="special">&gt;</span> <span class="identifier">acc3</span><span class="special">(</span>
    <span class="identifier">tag</span><span class="special">::</span><span class="identifier">peaks_over_threshold</span><span class="special">::</span><span class="identifier">threshold_value</span> <span class="special">=</span> <span class="identifier">threshold</span>
<span class="special">);</span>
<span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">pot_quantile</span><span class="special">&lt;</span><span class="identifier">right</span><span class="special">&gt;(</span><span class="identifier">with_threshold_probability</span><span class="special">)&gt;</span> <span class="special">&gt;</span> <span class="identifier">acc4</span><span class="special">(</span>
    <span class="identifier">tag</span><span class="special">::</span><span class="identifier">tail</span><span class="special">&lt;</span><span class="identifier">right</span><span class="special">&gt;::</span><span class="identifier">cache_size</span> <span class="special">=</span> <span class="number">2000</span>
  <span class="special">,</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">peaks_over_threshold_prob</span><span class="special">::</span><span class="identifier">threshold_probability</span> <span class="special">=</span> <span class="identifier">threshold_probability</span>
<span class="special">);</span>

<span class="keyword">for</span> <span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special">&lt;</span> <span class="number">100000</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
<span class="special">{</span>
    <span class="keyword">double</span> <span class="identifier">sample</span> <span class="special">=</span> <span class="identifier">normal</span><span class="special">();</span>
    <span class="identifier">acc1</span><span class="special">(</span><span class="identifier">sample</span><span class="special">);</span>
    <span class="identifier">acc2</span><span class="special">(</span><span class="identifier">sample</span><span class="special">);</span>
<span class="special">}</span>

<span class="keyword">for</span> <span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special">&lt;</span> <span class="number">100000</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
<span class="special">{</span>
    <span class="keyword">double</span> <span class="identifier">sample</span> <span class="special">=</span> <span class="identifier">exponential</span><span class="special">();</span>
    <span class="identifier">acc3</span><span class="special">(</span><span class="identifier">sample</span><span class="special">);</span>
    <span class="identifier">acc4</span><span class="special">(</span><span class="identifier">sample</span><span class="special">);</span>
<span class="special">}</span>

<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">quantile</span><span class="special">(</span><span class="identifier">acc1</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="identifier">alpha</span><span class="special">),</span> <span class="number">3.090232</span><span class="special">,</span> <span class="identifier">epsilon</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">quantile</span><span class="special">(</span><span class="identifier">acc2</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="identifier">alpha</span><span class="special">),</span> <span class="number">3.090232</span><span class="special">,</span> <span class="identifier">epsilon</span> <span class="special">);</span>

<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">quantile</span><span class="special">(</span><span class="identifier">acc3</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="identifier">alpha</span><span class="special">),</span> <span class="number">6.908</span><span class="special">,</span> <span class="identifier">epsilon</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">quantile</span><span class="special">(</span><span class="identifier">acc4</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="identifier">alpha</span><span class="special">),</span> <span class="number">6.908</span><span class="special">,</span> <span class="identifier">epsilon</span> <span class="special">);</span>
</pre>
<p>
          <span class="bold"><strong>See also</strong></span>
        </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
              <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/pot_quantile_impl.html" title="Struct template pot_quantile_impl">pot_quantile_impl</a></code>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.peaks_over_threshold" title="peaks_over_threshold and variants"><code class="literal">peaks_over_threshold</code></a>
            </li>
</ul></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="accumulators.user_s_guide.the_statistical_accumulators_library.pot_tail_mean"></a><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.pot_tail_mean" title="pot_tail_mean">pot_tail_mean</a>
</h4></div></div></div>
<p>
          Estimation of the (coherent) tail mean based on the peaks over threshold
          method (for both left and right tails). For implementation details, see
          <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/pot_tail_mean_impl.html" title="Struct template pot_tail_mean_impl">pot_tail_mean_impl</a></code>.
        </p>
<p>
          Both <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">pot_tail_mean</span><span class="special">&lt;</span><em class="replaceable"><code>left-or-right</code></em><span class="special">&gt;</span></code> and <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">pot_tail_mean_prob</span><span class="special">&lt;</span><em class="replaceable"><code>left-or-right</code></em><span class="special">&gt;</span></code>
          satisfy the <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">tail_mean</span></code> feature and can be extracted
          using the <code class="computeroutput"><span class="identifier">tail_mean</span><span class="special">()</span></code>
          extractor.
        </p>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Result Type</span></dt>
<dd>
<p>
</p>
<pre class="programlisting"><span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">fdiv</span><span class="special">&lt;</span><em class="replaceable"><code>sample-type</code></em><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">&gt;::</span><span class="identifier">result_type</span>
</pre>
<p>
              </p>
</dd>
<dt><span class="term">Depends On</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">pot_tail_mean</span><span class="special">&lt;</span><em class="replaceable"><code>left-or-right</code></em><span class="special">&gt;</span></code> depends on <code class="computeroutput"><span class="identifier">peaks_over_threshold</span><span class="special">&lt;</span><em class="replaceable"><code>left-or-right</code></em><span class="special">&gt;</span></code>
                and <code class="computeroutput"><span class="identifier">pot_quantile</span><span class="special">&lt;</span><em class="replaceable"><code>left-or-right</code></em><span class="special">&gt;</span></code>
                <br> <code class="computeroutput"><span class="identifier">pot_tail_mean_prob</span><span class="special">&lt;</span><em class="replaceable"><code>left-or-right</code></em><span class="special">&gt;</span></code>
                depends on <code class="computeroutput"><span class="identifier">peaks_over_threshold_prob</span><span class="special">&lt;</span><em class="replaceable"><code>left-or-right</code></em><span class="special">&gt;</span></code>
                and <code class="computeroutput"><span class="identifier">pot_quantile_prob</span><span class="special">&lt;</span><em class="replaceable"><code>left-or-right</code></em><span class="special">&gt;</span></code>
              </p></dd>
<dt><span class="term">Variants</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">pot_tail_mean_prob</span><span class="special">&lt;</span><em class="replaceable"><code>left-or-right</code></em><span class="special">&gt;</span></code>
              </p></dd>
<dt><span class="term">Initialization Parameters</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">peaks_over_threshold</span><span class="special">::</span><span class="identifier">threshold_value</span></code> <br> <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">peaks_over_threshold_prob</span><span class="special">::</span><span class="identifier">threshold_probability</span></code> <br> <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">tail</span><span class="special">&lt;</span><em class="replaceable"><code>left-or-right</code></em><span class="special">&gt;::</span><span class="identifier">cache_size</span></code>
              </p></dd>
<dt><span class="term">Accumulator Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Extractor Parameters</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">quantile_probability</span></code>
              </p></dd>
<dt><span class="term">Accumulator Complexity</span></dt>
<dd><p>
                TODO
              </p></dd>
<dt><span class="term">Extractor Complexity</span></dt>
<dd><p>
                TODO
              </p></dd>
</dl>
</div>
<p>
          <span class="bold"><strong>Header</strong></span>
        </p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><code class="computeroutput"><a class="link" href="reference.html#header.boost.accumulators.statistics.pot_tail_mean_hpp" title="Header &lt;boost/accumulators/statistics/pot_tail_mean.hpp&gt;">boost/accumulators/statistics/pot_tail_mean.hpp</a></code><span class="special">&gt;</span>
</pre>
<p>
          <span class="bold"><strong>Example</strong></span>
        </p>
<pre class="programlisting"><span class="comment">// TODO</span>
</pre>
<p>
          <span class="bold"><strong>See also</strong></span>
        </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
              <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/pot_tail_mean_impl.html" title="Struct template pot_tail_mean_impl">pot_tail_mean_impl</a></code>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.peaks_over_threshold" title="peaks_over_threshold and variants"><code class="literal">peaks_over_threshold</code></a>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.pot_quantile" title="pot_quantile and variants"><code class="literal">pot_quantile</code></a>
            </li>
</ul></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="accumulators.user_s_guide.the_statistical_accumulators_library.rolling_count"></a><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.rolling_count" title="rolling_count">rolling_count</a>
</h4></div></div></div>
<p>
          The rolling count is the current number of elements in the rolling window.
        </p>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Result Type</span></dt>
<dd>
<p>
</p>
<pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span></pre>
<p>
              </p>
</dd>
<dt><span class="term">Depends On</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">rolling_window_plus1</span></code>
              </p></dd>
<dt><span class="term">Variants</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Initialization Parameters</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">rolling_window</span><span class="special">::</span><span class="identifier">window_size</span></code>
              </p></dd>
<dt><span class="term">Accumulator Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Extractor Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Accumulator Complexity</span></dt>
<dd><p>
                O(1)
              </p></dd>
<dt><span class="term">Extractor Complexity</span></dt>
<dd><p>
                O(1)
              </p></dd>
</dl>
</div>
<p>
          <span class="bold"><strong>Header</strong></span>
        </p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><code class="computeroutput"><a class="link" href="reference.html#header.boost.accumulators.statistics.rolling_count_hpp" title="Header &lt;boost/accumulators/statistics/rolling_count.hpp&gt;">boost/accumulators/statistics/rolling_count.hpp</a></code><span class="special">&gt;</span>
</pre>
<p>
          <span class="bold"><strong>Example</strong></span>
        </p>
<pre class="programlisting"><span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">rolling_count</span><span class="special">&gt;</span> <span class="special">&gt;</span> <span class="identifier">acc</span><span class="special">(</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">rolling_window</span><span class="special">::</span><span class="identifier">window_size</span> <span class="special">=</span> <span class="number">3</span><span class="special">);</span>

<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span><span class="number">0u</span><span class="special">,</span> <span class="identifier">rolling_count</span><span class="special">(</span><span class="identifier">acc</span><span class="special">));</span>

<span class="identifier">acc</span><span class="special">(</span><span class="number">1</span><span class="special">);</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span><span class="number">1u</span><span class="special">,</span> <span class="identifier">rolling_count</span><span class="special">(</span><span class="identifier">acc</span><span class="special">));</span>

<span class="identifier">acc</span><span class="special">(</span><span class="number">1</span><span class="special">);</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span><span class="number">2u</span><span class="special">,</span> <span class="identifier">rolling_count</span><span class="special">(</span><span class="identifier">acc</span><span class="special">));</span>

<span class="identifier">acc</span><span class="special">(</span><span class="number">1</span><span class="special">);</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span><span class="number">3u</span><span class="special">,</span> <span class="identifier">rolling_count</span><span class="special">(</span><span class="identifier">acc</span><span class="special">));</span>

<span class="identifier">acc</span><span class="special">(</span><span class="number">1</span><span class="special">);</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span><span class="number">3u</span><span class="special">,</span> <span class="identifier">rolling_count</span><span class="special">(</span><span class="identifier">acc</span><span class="special">));</span>

<span class="identifier">acc</span><span class="special">(</span><span class="number">1</span><span class="special">);</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span><span class="number">3u</span><span class="special">,</span> <span class="identifier">rolling_count</span><span class="special">(</span><span class="identifier">acc</span><span class="special">));</span>
</pre>
<p>
          <span class="bold"><strong>See also</strong></span>
        </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
              <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/rolling_count_impl.html" title="Struct template rolling_count_impl">rolling_count_impl</a></code>
            </li></ul></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="accumulators.user_s_guide.the_statistical_accumulators_library.rolling_sum"></a><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.rolling_sum" title="rolling_sum">rolling_sum</a>
</h4></div></div></div>
<p>
          The rolling sum is the sum of the last <span class="emphasis"><em>N</em></span> samples.
        </p>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Result Type</span></dt>
<dd>
<p>
</p>
<pre class="programlisting"><em class="replaceable"><code>sample-type</code></em></pre>
<p>
              </p>
</dd>
<dt><span class="term">Depends On</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">rolling_window_plus1</span></code>
              </p></dd>
<dt><span class="term">Variants</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Initialization Parameters</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">rolling_window</span><span class="special">::</span><span class="identifier">window_size</span></code>
              </p></dd>
<dt><span class="term">Accumulator Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Extractor Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Accumulator Complexity</span></dt>
<dd><p>
                O(1)
              </p></dd>
<dt><span class="term">Extractor Complexity</span></dt>
<dd><p>
                O(1)
              </p></dd>
</dl>
</div>
<p>
          <span class="bold"><strong>Header</strong></span>
        </p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><code class="computeroutput"><a class="link" href="reference.html#header.boost.accumulators.statistics.rolling_sum_hpp" title="Header &lt;boost/accumulators/statistics/rolling_sum.hpp&gt;">boost/accumulators/statistics/rolling_sum.hpp</a></code><span class="special">&gt;</span>
</pre>
<p>
          <span class="bold"><strong>Example</strong></span>
        </p>
<pre class="programlisting"><span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">rolling_sum</span><span class="special">&gt;</span> <span class="special">&gt;</span> <span class="identifier">acc</span><span class="special">(</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">rolling_window</span><span class="special">::</span><span class="identifier">window_size</span> <span class="special">=</span> <span class="number">3</span><span class="special">);</span>

<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span><span class="number">0</span><span class="special">,</span> <span class="identifier">rolling_sum</span><span class="special">(</span><span class="identifier">acc</span><span class="special">));</span>

<span class="identifier">acc</span><span class="special">(</span><span class="number">1</span><span class="special">);</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span><span class="number">1</span><span class="special">,</span> <span class="identifier">rolling_sum</span><span class="special">(</span><span class="identifier">acc</span><span class="special">));</span>

<span class="identifier">acc</span><span class="special">(</span><span class="number">2</span><span class="special">);</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span><span class="number">3</span><span class="special">,</span> <span class="identifier">rolling_sum</span><span class="special">(</span><span class="identifier">acc</span><span class="special">));</span>

<span class="identifier">acc</span><span class="special">(</span><span class="number">3</span><span class="special">);</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span><span class="number">6</span><span class="special">,</span> <span class="identifier">rolling_sum</span><span class="special">(</span><span class="identifier">acc</span><span class="special">));</span>

<span class="identifier">acc</span><span class="special">(</span><span class="number">4</span><span class="special">);</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span><span class="number">9</span><span class="special">,</span> <span class="identifier">rolling_sum</span><span class="special">(</span><span class="identifier">acc</span><span class="special">));</span>

<span class="identifier">acc</span><span class="special">(</span><span class="number">5</span><span class="special">);</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span><span class="number">12</span><span class="special">,</span> <span class="identifier">rolling_sum</span><span class="special">(</span><span class="identifier">acc</span><span class="special">));</span>
</pre>
<p>
          <span class="bold"><strong>See also</strong></span>
        </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
              <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/rolling_sum_impl.html" title="Struct template rolling_sum_impl">rolling_sum_impl</a></code>
            </li></ul></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="accumulators.user_s_guide.the_statistical_accumulators_library.rolling_mean"></a><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.rolling_mean" title="rolling_mean">rolling_mean</a>
</h4></div></div></div>
<p>
          The rolling mean is the mean over the last <span class="emphasis"><em>N</em></span> samples.
          It is computed by dividing the rolling sum by the rolling count.
        </p>
<p>
          Lazy or iterative calculation of the mean over the last <span class="emphasis"><em>N</em></span>
          samples. The lazy calculation is associated with the <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">lazy_rolling_mean</span></code>
          feature, and the iterative calculation (which is the default) with the
          <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">immediate_rolling_mean</span></code> feature. Both
          can be extracted using the <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">rolling_mean</span><span class="special">()</span></code> extractor. For more implementation details,
          see <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/lazy_rolling_mean_impl.html" title="Struct template lazy_rolling_mean_impl">lazy_rolling_mean_impl</a></code>
          and <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/immed_1_3_2_6_3_23_1_1_6_1.html" title="Struct template immediate_rolling_mean_impl">immediate_rolling_mean_impl</a></code>
        </p>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Result Type</span></dt>
<dd>
<p>
</p>
<pre class="programlisting"><span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">fdiv</span><span class="special">&lt;</span><em class="replaceable"><code>sample-type</code></em><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">&gt;::</span><span class="identifier">result_type</span>
</pre>
<p>
              </p>
</dd>
<dt><span class="term">Depends On</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">lazy_rolling_mean</span></code>
                depends on <code class="computeroutput"><span class="identifier">rolling_sum</span></code>
                and <code class="computeroutput"><span class="identifier">rolling_count</span></code>
                <br> <code class="computeroutput"><span class="identifier">immediate_rolling_mean</span></code>
                depends on <code class="computeroutput"><span class="identifier">rolling_count</span></code>
              </p></dd>
<dt><span class="term">Variants</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">lazy_rolling_mean</span></code>
                (a.k.a. <code class="computeroutput"><span class="identifier">rolling_mean</span><span class="special">(</span><span class="identifier">lazy</span><span class="special">))</span></code> <br> <code class="computeroutput"><span class="identifier">immediate_rolling_mean</span></code>
                (a.k.a. <code class="computeroutput"><span class="identifier">rolling_mean</span><span class="special">(</span><span class="identifier">immediate</span><span class="special">)</span></code>)
              </p></dd>
<dt><span class="term">Initialization Parameters</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">rolling_window</span><span class="special">::</span><span class="identifier">window_size</span></code>
              </p></dd>
<dt><span class="term">Accumulator Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Extractor Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Accumulator Complexity</span></dt>
<dd><p>
                O(1)
              </p></dd>
<dt><span class="term">Extractor Complexity</span></dt>
<dd><p>
                O(1)
              </p></dd>
</dl>
</div>
<p>
          <span class="bold"><strong>Header</strong></span>
        </p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><code class="computeroutput"><a class="link" href="reference.html#header.boost.accumulators.statistics.rolling_mean_hpp" title="Header &lt;boost/accumulators/statistics/rolling_mean.hpp&gt;">boost/accumulators/statistics/rolling_mean.hpp</a></code><span class="special">&gt;</span>
</pre>
<p>
          <span class="bold"><strong>Example</strong></span>
        </p>
<pre class="programlisting"><span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">rolling_mean</span><span class="special">&gt;</span> <span class="special">&gt;</span> <span class="identifier">acc</span><span class="special">(</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">rolling_window</span><span class="special">::</span><span class="identifier">window_size</span> <span class="special">=</span> <span class="number">5</span><span class="special">);</span>

<span class="identifier">acc</span><span class="special">(</span><span class="number">1</span><span class="special">);</span>
<span class="identifier">acc</span><span class="special">(</span><span class="number">2</span><span class="special">);</span>
<span class="identifier">acc</span><span class="special">(</span><span class="number">3</span><span class="special">);</span>

<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">rolling_mean</span><span class="special">(</span><span class="identifier">acc</span><span class="special">),</span> <span class="number">2.0</span><span class="special">,</span> <span class="number">1e-6</span> <span class="special">);</span>

<span class="identifier">acc</span><span class="special">(</span><span class="number">4</span><span class="special">);</span>
<span class="identifier">acc</span><span class="special">(</span><span class="number">5</span><span class="special">);</span>
<span class="identifier">acc</span><span class="special">(</span><span class="number">6</span><span class="special">);</span>
<span class="identifier">acc</span><span class="special">(</span><span class="number">7</span><span class="special">);</span>

<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">rolling_mean</span><span class="special">(</span><span class="identifier">acc</span><span class="special">),</span> <span class="number">5.0</span><span class="special">,</span> <span class="number">1e-6</span> <span class="special">);</span>
</pre>
<p>
          <span class="bold"><strong>See also</strong></span>
        </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
              <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/lazy_rolling_mean_impl.html" title="Struct template lazy_rolling_mean_impl">lazy_rolling_mean_impl</a></code>
            </li>
<li class="listitem">
              <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/immed_1_3_2_6_3_23_1_1_6_1.html" title="Struct template immediate_rolling_mean_impl">immediate_rolling_mean_impl</a></code>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.rolling_count" title="rolling_count"><code class="literal">rolling_count</code></a>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.rolling_sum" title="rolling_sum"><code class="literal">rolling_sum</code></a>
            </li>
</ul></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="accumulators.user_s_guide.the_statistical_accumulators_library.rolling_moment"></a><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.rolling_moment" title="rolling_moment">rolling_moment</a>
</h4></div></div></div>
<p>
          rolling_moment&lt;M&gt; calculates the <span class="emphasis"><em>M</em></span>-th moment
          of the samples, which is defined as the sum of the <span class="emphasis"><em>M</em></span>-th
          power of the samples over the count of samples, over the last <span class="emphasis"><em>N</em></span>
          samples.
        </p>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Result Type</span></dt>
<dd>
<p>
</p>
<pre class="programlisting"><span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">fdiv</span><span class="special">&lt;</span><em class="replaceable"><code>sample-type</code></em><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">&gt;::</span><span class="identifier">result_type</span>
</pre>
<p>
              </p>
</dd>
<dt><span class="term">Depends On</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Variants</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Initialization Parameters</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">rolling_window</span><span class="special">::</span><span class="identifier">window_size</span></code>
              </p></dd>
<dt><span class="term">Accumulator Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Extractor Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Accumulator Complexity</span></dt>
<dd><p>
                O(1)
              </p></dd>
<dt><span class="term">Extractor Complexity</span></dt>
<dd><p>
                O(1)
              </p></dd>
</dl>
</div>
<p>
          <span class="bold"><strong>Header</strong></span>
        </p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><code class="computeroutput"><a class="link" href="reference.html#header.boost.accumulators.statistics.rolling_moment_hpp" title="Header &lt;boost/accumulators/statistics/rolling_moment.hpp&gt;">boost/accumulators/statistics/rolling_moment.hpp</a></code><span class="special">&gt;</span>
</pre>
<p>
          <span class="bold"><strong>Example</strong></span>
        </p>
<pre class="programlisting"><span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">rolling_moment</span><span class="special">&lt;</span><span class="number">2</span><span class="special">&gt;</span> <span class="special">&gt;</span> <span class="special">&gt;</span> <span class="identifier">acc</span><span class="special">(</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">rolling_window</span><span class="special">::</span><span class="identifier">window_size</span> <span class="special">=</span> <span class="number">3</span><span class="special">);</span>

<span class="identifier">acc</span><span class="special">(</span><span class="number">2</span><span class="special">);</span>
<span class="identifier">acc</span><span class="special">(</span><span class="number">4</span><span class="special">);</span>

<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">rolling_moment</span><span class="special">&lt;</span><span class="number">2</span><span class="special">&gt;(</span><span class="identifier">acc</span><span class="special">),</span> <span class="special">(</span><span class="number">4.0</span> <span class="special">+</span> <span class="number">16.0</span><span class="special">)/</span><span class="number">2</span><span class="special">,</span> <span class="number">1e-5</span> <span class="special">);</span>

<span class="identifier">acc</span><span class="special">(</span><span class="number">5</span><span class="special">);</span>
<span class="identifier">acc</span><span class="special">(</span><span class="number">6</span><span class="special">);</span>

<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">rolling_moment</span><span class="special">&lt;</span><span class="number">2</span><span class="special">&gt;(</span><span class="identifier">acc</span><span class="special">),</span> <span class="special">(</span><span class="number">16.0</span> <span class="special">+</span> <span class="number">25.0</span> <span class="special">+</span> <span class="number">36.0</span><span class="special">)/</span><span class="number">3</span><span class="special">,</span> <span class="number">1e-5</span> <span class="special">);</span>
</pre>
<p>
          <span class="bold"><strong>See also</strong></span>
        </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
              <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/rolling_moment_impl.html" title="Struct template rolling_moment_impl">rolling_moment_impl</a></code>
            </li></ul></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="accumulators.user_s_guide.the_statistical_accumulators_library.rolling_variance"></a><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.rolling_variance" title="rolling_variance">rolling_variance</a>
</h4></div></div></div>
<p>
          Lazy or iterative calculation of the variance over the last <span class="emphasis"><em>N</em></span>
          samples. The lazy calculation is associated with the <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">lazy_rolling_variance</span></code>
          feature, and the iterative calculation with the <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">immediate_rolling_variance</span></code>
          feature. Both can be extracted using the <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">rolling_variance</span><span class="special">()</span></code> extractor. For more implementation details,
          see <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/lazy_rolling_variance_impl.html" title="Struct template lazy_rolling_variance_impl">lazy_rolling_variance_impl</a></code>
          and <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/immed_1_3_2_6_3_26_1_1_6_1.html" title="Struct template immediate_rolling_variance_impl">immediate_rolling_variance_impl</a></code>
        </p>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Result Type</span></dt>
<dd>
<p>
</p>
<pre class="programlisting"><span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">fdiv</span><span class="special">&lt;</span><em class="replaceable"><code>sample-type</code></em><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">&gt;::</span><span class="identifier">result_type</span>
</pre>
<p>
              </p>
</dd>
<dt><span class="term">Depends On</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">lazy_rolling_variance</span></code>
                depends on <code class="computeroutput"><span class="identifier">rolling_moment</span><span class="special">&lt;</span><span class="number">2</span><span class="special">&gt;</span></code>, <code class="computeroutput"><span class="identifier">rolling_count</span></code>
                and <code class="computeroutput"><span class="identifier">rolling_mean</span></code>
                <br> <code class="computeroutput"><span class="identifier">immediate_rolling_variance</span></code>
                depends on <code class="computeroutput"><span class="identifier">rolling_count</span></code>
                and <code class="computeroutput"><span class="identifier">immediate_rolling_mean</span></code>
              </p></dd>
<dt><span class="term">Variants</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">lazy_rolling_variance</span></code>
                (a.k.a. <code class="computeroutput"><span class="identifier">rolling_variance</span><span class="special">(</span><span class="identifier">lazy</span><span class="special">))</span></code> <br> <code class="computeroutput"><span class="identifier">immediate_rolling_variance</span></code>
                (a.k.a. <code class="computeroutput"><span class="identifier">rolling_variance</span><span class="special">(</span><span class="identifier">immediate</span><span class="special">)</span></code>)
              </p></dd>
<dt><span class="term">Initialization Parameters</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">rolling_window</span><span class="special">::</span><span class="identifier">window_size</span></code>
              </p></dd>
<dt><span class="term">Accumulator Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Extractor Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Accumulator Complexity</span></dt>
<dd><p>
                O(1)
              </p></dd>
<dt><span class="term">Extractor Complexity</span></dt>
<dd><p>
                O(1)
              </p></dd>
</dl>
</div>
<p>
          <span class="bold"><strong>Header</strong></span>
        </p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><code class="computeroutput"><a class="link" href="reference.html#header.boost.accumulators.statistics.rolling_variance_hpp" title="Header &lt;boost/accumulators/statistics/rolling_variance.hpp&gt;">boost/accumulators/statistics/rolling_variance.hpp</a></code><span class="special">&gt;</span>
</pre>
<p>
          <span class="bold"><strong>Example</strong></span>
        </p>
<pre class="programlisting"><span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">rolling_variance</span><span class="special">&gt;</span> <span class="special">&gt;</span> <span class="identifier">acc</span><span class="special">(</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">rolling_window</span><span class="special">::</span><span class="identifier">window_size</span> <span class="special">=</span> <span class="number">4</span><span class="special">);</span>

<span class="identifier">acc</span><span class="special">(</span><span class="number">1.2</span><span class="special">);</span>

<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">rolling_variance</span><span class="special">(</span><span class="identifier">acc</span><span class="special">),</span> <span class="number">0.0</span><span class="special">,</span> <span class="number">1e-10</span> <span class="special">);</span> <span class="comment">// variance is not defined for a single sample</span>

<span class="identifier">acc</span><span class="special">(</span><span class="number">2.3</span><span class="special">);</span>
<span class="identifier">acc</span><span class="special">(</span><span class="number">3.4</span><span class="special">);</span>

<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">rolling_variance</span><span class="special">(</span><span class="identifier">acc</span><span class="special">),</span> <span class="number">1.21</span><span class="special">,</span> <span class="number">1e-10</span> <span class="special">);</span> <span class="comment">// variance over samples 1-3</span>

<span class="identifier">acc</span><span class="special">(</span><span class="number">4.5</span><span class="special">);</span>
<span class="identifier">acc</span><span class="special">(</span><span class="number">0.4</span><span class="special">);</span>
<span class="identifier">acc</span><span class="special">(</span><span class="number">2.2</span><span class="special">);</span>
<span class="identifier">acc</span><span class="special">(</span><span class="number">7.1</span><span class="special">);</span>

<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">rolling_variance</span><span class="special">(</span><span class="identifier">acc</span><span class="special">),</span> <span class="number">8.41666666666667</span><span class="special">,</span> <span class="number">1e-10</span> <span class="special">);</span> <span class="comment">// variance over samples 4-7</span>
</pre>
<p>
          <span class="bold"><strong>See also</strong></span>
        </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
              <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/lazy_rolling_variance_impl.html" title="Struct template lazy_rolling_variance_impl">lazy_rolling_variance_impl</a></code>
            </li>
<li class="listitem">
              <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/immed_1_3_2_6_3_26_1_1_6_1.html" title="Struct template immediate_rolling_variance_impl">immediate_rolling_variance_impl</a></code>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.rolling_count" title="rolling_count"><code class="literal">rolling_count</code></a>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.rolling_mean" title="rolling_mean"><code class="literal">rolling_mean</code></a>
            </li>
<li class="listitem">
              <a class="link" href="../"><code class="literal">immediate_rolling_mean</code></a>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.rolling_moment" title="rolling_moment"><code class="literal">rolling_moment</code></a>
            </li>
</ul></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="accumulators.user_s_guide.the_statistical_accumulators_library.skewness"></a><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.skewness" title="skewness">skewness</a>
</h4></div></div></div>
<p>
          The skewness of a sample distribution is defined as the ratio of the 3rd
          central moment and the <code class="literal">3/2</code>-th power of the 2nd central
          moment (the variance) of the samples 3. For implementation details, see
          <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/skewness_impl.html" title="Struct template skewness_impl">skewness_impl</a></code>.
        </p>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Result Type</span></dt>
<dd>
<p>
</p>
<pre class="programlisting"><span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">fdiv</span><span class="special">&lt;</span><em class="replaceable"><code>sample-type</code></em><span class="special">,</span> <em class="replaceable"><code>sample-type</code></em><span class="special">&gt;::</span><span class="identifier">result_type</span>
</pre>
<p>
              </p>
</dd>
<dt><span class="term">Depends On</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">mean</span></code> <br> <code class="computeroutput"><span class="identifier">moment</span><span class="special">&lt;</span><span class="number">2</span><span class="special">&gt;</span></code>
                <br> <code class="computeroutput"><span class="identifier">moment</span><span class="special">&lt;</span><span class="number">3</span><span class="special">&gt;</span></code>
              </p></dd>
<dt><span class="term">Variants</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Initialization Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Accumulator Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Extractor Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Accumulator Complexity</span></dt>
<dd><p>
                O(1)
              </p></dd>
<dt><span class="term">Extractor Complexity</span></dt>
<dd><p>
                O(1)
              </p></dd>
</dl>
</div>
<p>
          <span class="bold"><strong>Header</strong></span>
        </p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><code class="computeroutput"><a class="link" href="reference.html#header.boost.accumulators.statistics.skewness_hpp" title="Header &lt;boost/accumulators/statistics/skewness.hpp&gt;">boost/accumulators/statistics/skewness.hpp</a></code><span class="special">&gt;</span>
</pre>
<p>
          <span class="bold"><strong>Example</strong></span>
        </p>
<pre class="programlisting"><span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">skewness</span> <span class="special">&gt;</span> <span class="special">&gt;</span> <span class="identifier">acc2</span><span class="special">;</span>

<span class="identifier">acc2</span><span class="special">(</span><span class="number">2</span><span class="special">);</span>
<span class="identifier">acc2</span><span class="special">(</span><span class="number">7</span><span class="special">);</span>
<span class="identifier">acc2</span><span class="special">(</span><span class="number">4</span><span class="special">);</span>
<span class="identifier">acc2</span><span class="special">(</span><span class="number">9</span><span class="special">);</span>
<span class="identifier">acc2</span><span class="special">(</span><span class="number">3</span><span class="special">);</span>

<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="identifier">mean</span><span class="special">(</span><span class="identifier">acc2</span><span class="special">),</span> <span class="number">5</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="identifier">accumulators</span><span class="special">::</span><span class="identifier">moment</span><span class="special">&lt;</span><span class="number">2</span><span class="special">&gt;(</span><span class="identifier">acc2</span><span class="special">),</span> <span class="number">159.</span><span class="special">/</span><span class="number">5.</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="identifier">accumulators</span><span class="special">::</span><span class="identifier">moment</span><span class="special">&lt;</span><span class="number">3</span><span class="special">&gt;(</span><span class="identifier">acc2</span><span class="special">),</span> <span class="number">1171.</span><span class="special">/</span><span class="number">5.</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">skewness</span><span class="special">(</span><span class="identifier">acc2</span><span class="special">),</span> <span class="number">0.406040288214</span><span class="special">,</span> <span class="number">1e-6</span> <span class="special">);</span>
</pre>
<p>
          <span class="bold"><strong>See also</strong></span>
        </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
              <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/skewness_impl.html" title="Struct template skewness_impl">skewness_impl</a></code>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.mean" title="mean and variants"><code class="literal">mean</code></a>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.moment" title="moment"><code class="literal">moment</code></a>
            </li>
</ul></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="accumulators.user_s_guide.the_statistical_accumulators_library.sum"></a><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.sum" title="sum and variants">sum
        <span class="emphasis"><em>and variants</em></span></a>
</h4></div></div></div>
<p>
          For summing the samples, weights or variates. The default implementation
          uses the standard sum operation, but variants using the Kahan summation
          algorithm are also provided.
        </p>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Result Type</span></dt>
<dd><p>
                <code class="computeroutput"><em class="replaceable"><code>sample-type</code></em></code> for summing samples <br> <code class="computeroutput"><em class="replaceable"><code>weight-type</code></em></code> for summing
                weights <br> <code class="computeroutput"><em class="replaceable"><code>variate-type</code></em></code> for summing variates
              </p></dd>
<dt><span class="term">Depends On</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Variants</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">sum</span></code> <br> <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">sum_of_weights</span></code>
                <br> <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">sum_of_variates</span><span class="special">&lt;</span><em class="replaceable"><code>variate-type</code></em><span class="special">,</span> <em class="replaceable"><code>variate-tag</code></em><span class="special">&gt;</span></code>
                <br> <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">sum_kahan</span></code> (a.k.a. <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">sum</span><span class="special">(</span><span class="identifier">kahan</span><span class="special">)</span></code>)
                <br> <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">sum_of_weights_kahan</span></code> (a.k.a. <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">sum_of_weights</span><span class="special">(</span><span class="identifier">kahan</span><span class="special">)</span></code>)
                <br> <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">sum_of_variates_kahan</span><span class="special">&lt;</span><em class="replaceable"><code>variate-type</code></em><span class="special">,</span> <em class="replaceable"><code>variate-tag</code></em><span class="special">&gt;</span></code>
                <br>
              </p></dd>
<dt><span class="term">Initialization Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Accumulator Parameters</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">weight</span></code> for summing
                weights <br> <code class="computeroutput"><em class="replaceable"><code>variate-tag</code></em></code> for summing variates
              </p></dd>
<dt><span class="term">Extractor Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Accumulator Complexity</span></dt>
<dd><p>
                O(1). Note that the Kahan sum performs four floating-point sum operations
                per accumulated value, whereas the naive sum performs only one.
              </p></dd>
<dt><span class="term">Extractor Complexity</span></dt>
<dd><p>
                O(1)
              </p></dd>
</dl>
</div>
<p>
          <span class="bold"><strong>Header</strong></span>
        </p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><code class="computeroutput"><a class="link" href="reference.html#header.boost.accumulators.statistics.sum_hpp" title="Header &lt;boost/accumulators/statistics/sum.hpp&gt;">boost/accumulators/statistics/sum.hpp</a></code><span class="special">&gt;</span>
<span class="preprocessor">#include</span> <span class="special">&lt;</span><code class="computeroutput"><a class="link" href="reference.html#header.boost.accumulators.statistics.sum_kahan_hpp" title="Header &lt;boost/accumulators/statistics/sum_kahan.hpp&gt;">boost/accumulators/statistics/sum_kahan.hpp</a></code><span class="special">&gt;</span>
</pre>
<p>
          <span class="bold"><strong>Example</strong></span>
        </p>
<pre class="programlisting"><span class="identifier">accumulator_set</span><span class="special">&lt;</span>
    <span class="keyword">int</span>
  <span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span>
        <span class="identifier">tag</span><span class="special">::</span><span class="identifier">sum</span>
      <span class="special">,</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">sum_of_weights</span>
      <span class="special">,</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">sum_of_variates</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">,</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">covariate1</span><span class="special">&gt;</span>
    <span class="special">&gt;</span>
  <span class="special">,</span> <span class="keyword">int</span>
<span class="special">&gt;</span> <span class="identifier">acc</span><span class="special">;</span>

<span class="identifier">acc</span><span class="special">(</span><span class="number">1</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">2</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="number">3</span><span class="special">);</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span><span class="number">2</span><span class="special">,</span> <span class="identifier">sum</span><span class="special">(</span><span class="identifier">acc</span><span class="special">));</span>  <span class="comment">// weighted sample = 1 * 2</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span><span class="number">2</span><span class="special">,</span> <span class="identifier">sum_of_weights</span><span class="special">(</span><span class="identifier">acc</span><span class="special">));</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span><span class="number">3</span><span class="special">,</span> <span class="identifier">sum_of_variates</span><span class="special">(</span><span class="identifier">acc</span><span class="special">));</span>

<span class="identifier">acc</span><span class="special">(</span><span class="number">2</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">4</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="number">6</span><span class="special">);</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span><span class="number">10</span><span class="special">,</span> <span class="identifier">sum</span><span class="special">(</span><span class="identifier">acc</span><span class="special">));</span> <span class="comment">// weighted sample = 2 * 4</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span><span class="number">6</span><span class="special">,</span> <span class="identifier">sum_of_weights</span><span class="special">(</span><span class="identifier">acc</span><span class="special">));</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span><span class="number">9</span><span class="special">,</span> <span class="identifier">sum_of_variates</span><span class="special">(</span><span class="identifier">acc</span><span class="special">));</span>

<span class="identifier">acc</span><span class="special">(</span><span class="number">3</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">6</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="number">9</span><span class="special">);</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span><span class="number">28</span><span class="special">,</span> <span class="identifier">sum</span><span class="special">(</span><span class="identifier">acc</span><span class="special">));</span> <span class="comment">// weighted sample = 3 * 6</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span><span class="number">12</span><span class="special">,</span> <span class="identifier">sum_of_weights</span><span class="special">(</span><span class="identifier">acc</span><span class="special">));</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span><span class="number">18</span><span class="special">,</span> <span class="identifier">sum_of_variates</span><span class="special">(</span><span class="identifier">acc</span><span class="special">));</span>

<span class="comment">// demonstrate Kahan summation</span>
<span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">float</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">sum_kahan</span><span class="special">&gt;</span> <span class="special">&gt;</span> <span class="identifier">acc</span><span class="special">;</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span><span class="number">0.0f</span><span class="special">,</span> <span class="identifier">sum_kahan</span><span class="special">(</span><span class="identifier">acc</span><span class="special">));</span>
<span class="keyword">for</span> <span class="special">(</span><span class="identifier">size_t</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special">&lt;</span> <span class="number">1e6</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span> <span class="special">{</span>
  <span class="identifier">acc</span><span class="special">(</span><span class="number">1e-6f</span><span class="special">);</span>
<span class="special">}</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span><span class="number">1.0f</span><span class="special">,</span> <span class="identifier">sum_kahan</span><span class="special">(</span><span class="identifier">acc</span><span class="special">));</span>
</pre>
<p>
          <span class="bold"><strong>See also</strong></span>
        </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
              <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/sum_impl.html" title="Struct template sum_impl">sum_impl</a></code>
            </li>
<li class="listitem">
              <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/sum_kahan_impl.html" title="Struct template sum_kahan_impl">sum_kahan_impl</a></code>
            </li>
</ul></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="accumulators.user_s_guide.the_statistical_accumulators_library.tail"></a><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.tail" title="tail">tail</a>
</h4></div></div></div>
<p>
          Tracks the largest or smallest <code class="literal">N</code> values. <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">tail</span><span class="special">&lt;</span><span class="identifier">right</span><span class="special">&gt;</span></code>
          tracks the largest <code class="literal">N</code>, and <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">tail</span><span class="special">&lt;</span><span class="identifier">left</span><span class="special">&gt;</span></code> tracks the smallest. The parameter
          <code class="literal">N</code> is specified with the <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">tail</span><span class="special">&lt;</span><em class="replaceable"><code>left-or-right</code></em><span class="special">&gt;::</span><span class="identifier">cache_size</span></code> initialization parameter.
          For implementation details, see <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/tail_impl.html" title="Struct template tail_impl">tail_impl</a></code>.
        </p>
<p>
          Both <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">tail</span><span class="special">&lt;</span><span class="identifier">left</span><span class="special">&gt;</span></code>
          and <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">tail</span><span class="special">&lt;</span><span class="identifier">right</span><span class="special">&gt;</span></code>
          satisfy the <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">abstract_tail</span></code> feature and can be extracted
          with the <code class="computeroutput"><span class="identifier">tail</span><span class="special">()</span></code>
          extractor.
        </p>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Result Type</span></dt>
<dd>
<p>
</p>
<pre class="programlisting"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">iterator_range</span><span class="special">&lt;</span>
    <span class="identifier">boost</span><span class="special">::</span><span class="identifier">reverse_iterator</span><span class="special">&lt;</span>
        <span class="identifier">boost</span><span class="special">::</span><span class="identifier">permutation_iterator</span><span class="special">&lt;</span>
            <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span><em class="replaceable"><code>sample-type</code></em><span class="special">&gt;::</span><span class="identifier">const_iterator</span>  <span class="comment">// samples</span>
          <span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">&gt;::</span><span class="identifier">iterator</span>          <span class="comment">// indices</span>
        <span class="special">&gt;</span>
    <span class="special">&gt;</span>
<span class="special">&gt;</span>
</pre>
<p>
              </p>
</dd>
<dt><span class="term">Depends On</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Variants</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">abstract_tail</span></code>
              </p></dd>
<dt><span class="term">Initialization Parameters</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">tail</span><span class="special">&lt;</span><em class="replaceable"><code>left-or-right</code></em><span class="special">&gt;::</span><span class="identifier">cache_size</span></code>
              </p></dd>
<dt><span class="term">Accumulator Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Extractor Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Accumulator Complexity</span></dt>
<dd><p>
                O(log N), where N is the cache size
              </p></dd>
<dt><span class="term">Extractor Complexity</span></dt>
<dd><p>
                O(N log N), where N is the cache size
              </p></dd>
</dl>
</div>
<p>
          <span class="bold"><strong>Header</strong></span>
        </p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><code class="computeroutput"><a class="link" href="reference.html#header.boost.accumulators.statistics.tail_hpp" title="Header &lt;boost/accumulators/statistics/tail.hpp&gt;">boost/accumulators/statistics/tail.hpp</a></code><span class="special">&gt;</span>
</pre>
<p>
          <span class="bold"><strong>Example</strong></span>
        </p>
<p>
          See the Example for <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.tail_variate" title="tail_variate"><code class="literal">tail_variate</code></a>.
        </p>
<p>
          <span class="bold"><strong>See also</strong></span>
        </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
              <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/tail_impl.html" title="Struct template tail_impl">tail_impl</a></code>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.tail_variate" title="tail_variate"><code class="literal">tail_variate</code></a>
            </li>
</ul></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="accumulators.user_s_guide.the_statistical_accumulators_library.coherent_tail_mean"></a><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.coherent_tail_mean" title="coherent_tail_mean">coherent_tail_mean</a>
</h4></div></div></div>
<p>
          Estimation of the coherent tail mean based on order statistics (for both
          left and right tails). The left coherent tail mean feature is <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">coherent_tail_mean</span><span class="special">&lt;</span><span class="identifier">left</span><span class="special">&gt;</span></code>,
          and the right coherent tail mean feature is <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">coherent_tail_mean</span><span class="special">&lt;</span><span class="identifier">right</span><span class="special">&gt;</span></code>. They both share the <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">tail_mean</span></code> feature and can be extracted
          with the <code class="computeroutput"><span class="identifier">tail_mean</span><span class="special">()</span></code>
          extractor. For more implementation details, see <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/coherent_tail_mean_impl.html" title="Struct template coherent_tail_mean_impl">coherent_tail_mean_impl</a></code>
        </p>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Result Type</span></dt>
<dd>
<p>
</p>
<pre class="programlisting"><span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">fdiv</span><span class="special">&lt;</span><em class="replaceable"><code>sample-type</code></em><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">&gt;::</span><span class="identifier">result_type</span>
</pre>
<p>
              </p>
</dd>
<dt><span class="term">Depends On</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">count</span></code> <br> <code class="computeroutput"><span class="identifier">quantile</span></code> <br> <code class="computeroutput"><span class="identifier">non_coherent_tail_mean</span><span class="special">&lt;</span><em class="replaceable"><code>left-or-right</code></em><span class="special">&gt;</span></code>
              </p></dd>
<dt><span class="term">Variants</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Initialization Parameters</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">tail</span><span class="special">&lt;</span><em class="replaceable"><code>left-or-right</code></em><span class="special">&gt;::</span><span class="identifier">cache_size</span></code>
              </p></dd>
<dt><span class="term">Accumulator Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Extractor Parameters</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">quantile_probability</span></code>
              </p></dd>
<dt><span class="term">Accumulator Complexity</span></dt>
<dd><p>
                O(log N), where N is the cache size
              </p></dd>
<dt><span class="term">Extractor Complexity</span></dt>
<dd><p>
                O(N log N), where N is the cache size
              </p></dd>
</dl>
</div>
<p>
          <span class="bold"><strong>Header</strong></span>
        </p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><code class="computeroutput"><a class="link" href="reference.html#header.boost.accumulators.statistics.tail_mean_hpp" title="Header &lt;boost/accumulators/statistics/tail_mean.hpp&gt;">boost/accumulators/statistics/tail_mean.hpp</a></code><span class="special">&gt;</span>
</pre>
<p>
          <span class="bold"><strong>Example</strong></span>
        </p>
<p>
          See the example for <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.non_coherent_tail_mean" title="non_coherent_tail_mean"><code class="literal">non_coherent_tail_mean</code></a>.
        </p>
<p>
          <span class="bold"><strong>See also</strong></span>
        </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
              <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/coherent_tail_mean_impl.html" title="Struct template coherent_tail_mean_impl">coherent_tail_mean_impl</a></code>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.count" title="count"><code class="literal">count</code></a>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.extended_p_square_quantile" title="extended_p_square_quantile and variants"><code class="literal">extended_p_square_quantile</code></a>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.pot_quantile" title="pot_quantile and variants"><code class="literal">pot_quantile</code></a>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.tail_quantile" title="tail_quantile"><code class="literal">tail_quantile</code></a>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.non_coherent_tail_mean" title="non_coherent_tail_mean"><code class="literal">non_coherent_tail_mean</code></a>
            </li>
</ul></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="accumulators.user_s_guide.the_statistical_accumulators_library.non_coherent_tail_mean"></a><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.non_coherent_tail_mean" title="non_coherent_tail_mean">non_coherent_tail_mean</a>
</h4></div></div></div>
<p>
          Estimation of the (non-coherent) tail mean based on order statistics (for
          both left and right tails). The left non-coherent tail mean feature is
          <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">non_coherent_tail_mean</span><span class="special">&lt;</span><span class="identifier">left</span><span class="special">&gt;</span></code>,
          and the right non-choherent tail mean feature is <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">non_coherent_tail_mean</span><span class="special">&lt;</span><span class="identifier">right</span><span class="special">&gt;</span></code>. They both share the <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">abstract_non_coherent_tail_mean</span></code> feature
          and can be extracted with the <code class="computeroutput"><span class="identifier">non_coherent_tail_mean</span><span class="special">()</span></code> extractor. For more implementation details,
          see <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/non_c_1_3_2_6_3_33_1_1_6_2.html" title="Struct template non_coherent_tail_mean_impl">non_coherent_tail_mean_impl</a></code>
        </p>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Result Type</span></dt>
<dd>
<p>
</p>
<pre class="programlisting"><span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">fdiv</span><span class="special">&lt;</span><em class="replaceable"><code>sample-type</code></em><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">&gt;::</span><span class="identifier">result_type</span>
</pre>
<p>
              </p>
</dd>
<dt><span class="term">Depends On</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">count</span></code> <br> <code class="computeroutput"><span class="identifier">tail</span><span class="special">&lt;</span><em class="replaceable"><code>left-or-right</code></em><span class="special">&gt;</span></code>
              </p></dd>
<dt><span class="term">Variants</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">abstract_non_coherent_tail_mean</span></code>
              </p></dd>
<dt><span class="term">Initialization Parameters</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">tail</span><span class="special">&lt;</span><em class="replaceable"><code>left-or-right</code></em><span class="special">&gt;::</span><span class="identifier">cache_size</span></code>
              </p></dd>
<dt><span class="term">Accumulator Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Extractor Parameters</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">quantile_probability</span></code>
              </p></dd>
<dt><span class="term">Accumulator Complexity</span></dt>
<dd><p>
                O(log N), where N is the cache size
              </p></dd>
<dt><span class="term">Extractor Complexity</span></dt>
<dd><p>
                O(N log N), where N is the cache size
              </p></dd>
</dl>
</div>
<p>
          <span class="bold"><strong>Header</strong></span>
        </p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><code class="computeroutput"><a class="link" href="reference.html#header.boost.accumulators.statistics.tail_mean_hpp" title="Header &lt;boost/accumulators/statistics/tail_mean.hpp&gt;">boost/accumulators/statistics/tail_mean.hpp</a></code><span class="special">&gt;</span>
</pre>
<p>
          <span class="bold"><strong>Example</strong></span>
        </p>
<pre class="programlisting"><span class="comment">// tolerance in %</span>
<span class="keyword">double</span> <span class="identifier">epsilon</span> <span class="special">=</span> <span class="number">1</span><span class="special">;</span>

<span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">n</span> <span class="special">=</span> <span class="number">100000</span><span class="special">;</span> <span class="comment">// number of MC steps</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">c</span> <span class="special">=</span>  <span class="number">10000</span><span class="special">;</span> <span class="comment">// cache size</span>

<span class="keyword">typedef</span> <span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">non_coherent_tail_mean</span><span class="special">&lt;</span><span class="identifier">right</span><span class="special">&gt;,</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">tail_quantile</span><span class="special">&lt;</span><span class="identifier">right</span><span class="special">&gt;</span> <span class="special">&gt;</span> <span class="special">&gt;</span> <span class="identifier">accumulator_t_right1</span><span class="special">;</span>
<span class="keyword">typedef</span> <span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">non_coherent_tail_mean</span><span class="special">&lt;</span><span class="identifier">left</span><span class="special">&gt;,</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">tail_quantile</span><span class="special">&lt;</span><span class="identifier">left</span><span class="special">&gt;</span> <span class="special">&gt;</span> <span class="special">&gt;</span> <span class="identifier">accumulator_t_left1</span><span class="special">;</span>
<span class="keyword">typedef</span> <span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">coherent_tail_mean</span><span class="special">&lt;</span><span class="identifier">right</span><span class="special">&gt;,</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">tail_quantile</span><span class="special">&lt;</span><span class="identifier">right</span><span class="special">&gt;</span> <span class="special">&gt;</span> <span class="special">&gt;</span> <span class="identifier">accumulator_t_right2</span><span class="special">;</span>
<span class="keyword">typedef</span> <span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">coherent_tail_mean</span><span class="special">&lt;</span><span class="identifier">left</span><span class="special">&gt;,</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">tail_quantile</span><span class="special">&lt;</span><span class="identifier">left</span><span class="special">&gt;</span> <span class="special">&gt;</span> <span class="special">&gt;</span> <span class="identifier">accumulator_t_left2</span><span class="special">;</span>

<span class="identifier">accumulator_t_right1</span> <span class="identifier">acc0</span><span class="special">(</span> <span class="identifier">right_tail_cache_size</span> <span class="special">=</span> <span class="identifier">c</span> <span class="special">);</span>
<span class="identifier">accumulator_t_left1</span> <span class="identifier">acc1</span><span class="special">(</span> <span class="identifier">left_tail_cache_size</span> <span class="special">=</span> <span class="identifier">c</span> <span class="special">);</span>
<span class="identifier">accumulator_t_right2</span> <span class="identifier">acc2</span><span class="special">(</span> <span class="identifier">right_tail_cache_size</span> <span class="special">=</span> <span class="identifier">c</span> <span class="special">);</span>
<span class="identifier">accumulator_t_left2</span> <span class="identifier">acc3</span><span class="special">(</span> <span class="identifier">left_tail_cache_size</span> <span class="special">=</span> <span class="identifier">c</span> <span class="special">);</span>

<span class="comment">// a random number generator</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">lagged_fibonacci607</span> <span class="identifier">rng</span><span class="special">;</span>

<span class="keyword">for</span> <span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special">&lt;</span> <span class="identifier">n</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
<span class="special">{</span>
    <span class="keyword">double</span> <span class="identifier">sample</span> <span class="special">=</span> <span class="identifier">rng</span><span class="special">();</span>
    <span class="identifier">acc0</span><span class="special">(</span><span class="identifier">sample</span><span class="special">);</span>
    <span class="identifier">acc1</span><span class="special">(</span><span class="identifier">sample</span><span class="special">);</span>
    <span class="identifier">acc2</span><span class="special">(</span><span class="identifier">sample</span><span class="special">);</span>
    <span class="identifier">acc3</span><span class="special">(</span><span class="identifier">sample</span><span class="special">);</span>
<span class="special">}</span>

<span class="comment">// check uniform distribution</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">non_coherent_tail_mean</span><span class="special">(</span><span class="identifier">acc0</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.95</span><span class="special">),</span> <span class="number">0.975</span><span class="special">,</span> <span class="identifier">epsilon</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">non_coherent_tail_mean</span><span class="special">(</span><span class="identifier">acc0</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.975</span><span class="special">),</span> <span class="number">0.9875</span><span class="special">,</span> <span class="identifier">epsilon</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">non_coherent_tail_mean</span><span class="special">(</span><span class="identifier">acc0</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.99</span><span class="special">),</span> <span class="number">0.995</span><span class="special">,</span> <span class="identifier">epsilon</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">non_coherent_tail_mean</span><span class="special">(</span><span class="identifier">acc0</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.999</span><span class="special">),</span> <span class="number">0.9995</span><span class="special">,</span> <span class="identifier">epsilon</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">non_coherent_tail_mean</span><span class="special">(</span><span class="identifier">acc1</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.05</span><span class="special">),</span> <span class="number">0.025</span><span class="special">,</span> <span class="identifier">epsilon</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">non_coherent_tail_mean</span><span class="special">(</span><span class="identifier">acc1</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.025</span><span class="special">),</span> <span class="number">0.0125</span><span class="special">,</span> <span class="identifier">epsilon</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">non_coherent_tail_mean</span><span class="special">(</span><span class="identifier">acc1</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.01</span><span class="special">),</span> <span class="number">0.005</span><span class="special">,</span> <span class="number">5</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">non_coherent_tail_mean</span><span class="special">(</span><span class="identifier">acc1</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.001</span><span class="special">),</span> <span class="number">0.0005</span><span class="special">,</span> <span class="number">10</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">tail_mean</span><span class="special">(</span><span class="identifier">acc2</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.95</span><span class="special">),</span> <span class="number">0.975</span><span class="special">,</span> <span class="identifier">epsilon</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">tail_mean</span><span class="special">(</span><span class="identifier">acc2</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.975</span><span class="special">),</span> <span class="number">0.9875</span><span class="special">,</span> <span class="identifier">epsilon</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">tail_mean</span><span class="special">(</span><span class="identifier">acc2</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.99</span><span class="special">),</span> <span class="number">0.995</span><span class="special">,</span> <span class="identifier">epsilon</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">tail_mean</span><span class="special">(</span><span class="identifier">acc2</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.999</span><span class="special">),</span> <span class="number">0.9995</span><span class="special">,</span> <span class="identifier">epsilon</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">tail_mean</span><span class="special">(</span><span class="identifier">acc3</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.05</span><span class="special">),</span> <span class="number">0.025</span><span class="special">,</span> <span class="identifier">epsilon</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">tail_mean</span><span class="special">(</span><span class="identifier">acc3</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.025</span><span class="special">),</span> <span class="number">0.0125</span><span class="special">,</span> <span class="identifier">epsilon</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">tail_mean</span><span class="special">(</span><span class="identifier">acc3</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.01</span><span class="special">),</span> <span class="number">0.005</span><span class="special">,</span> <span class="number">5</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">tail_mean</span><span class="special">(</span><span class="identifier">acc3</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.001</span><span class="special">),</span> <span class="number">0.0005</span><span class="special">,</span> <span class="number">10</span> <span class="special">);</span>
</pre>
<p>
          <span class="bold"><strong>See also</strong></span>
        </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
              <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/non_c_1_3_2_6_3_33_1_1_6_2.html" title="Struct template non_coherent_tail_mean_impl">non_coherent_tail_mean_impl</a></code>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.count" title="count"><code class="literal">count</code></a>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.tail" title="tail"><code class="literal">tail</code></a>
            </li>
</ul></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="accumulators.user_s_guide.the_statistical_accumulators_library.tail_quantile"></a><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.tail_quantile" title="tail_quantile">tail_quantile</a>
</h4></div></div></div>
<p>
          Tail quantile estimation based on order statistics (for both left and right
          tails). The left tail quantile feature is <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">tail_quantile</span><span class="special">&lt;</span><span class="identifier">left</span><span class="special">&gt;</span></code>, and the right tail quantile feature
          is <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">tail_quantile</span><span class="special">&lt;</span><span class="identifier">right</span><span class="special">&gt;</span></code>.
          They both share the <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">quantile</span></code>
          feature and can be extracted with the <code class="computeroutput"><span class="identifier">quantile</span><span class="special">()</span></code> extractor. For more implementation details,
          see <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/tail_quantile_impl.html" title="Struct template tail_quantile_impl">tail_quantile_impl</a></code>
        </p>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Result Type</span></dt>
<dd>
<p>
</p>
<pre class="programlisting"><em class="replaceable"><code>sample-type</code></em>
</pre>
<p>
              </p>
</dd>
<dt><span class="term">Depends On</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">count</span></code> <br> <code class="computeroutput"><span class="identifier">tail</span><span class="special">&lt;</span><em class="replaceable"><code>left-or-right</code></em><span class="special">&gt;</span></code>
              </p></dd>
<dt><span class="term">Variants</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Initialization Parameters</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">tail</span><span class="special">&lt;</span><em class="replaceable"><code>left-or-right</code></em><span class="special">&gt;::</span><span class="identifier">cache_size</span></code>
              </p></dd>
<dt><span class="term">Accumulator Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Extractor Parameters</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">quantile_probability</span></code>
              </p></dd>
<dt><span class="term">Accumulator Complexity</span></dt>
<dd><p>
                O(log N), where N is the cache size
              </p></dd>
<dt><span class="term">Extractor Complexity</span></dt>
<dd><p>
                O(N log N), where N is the cache size
              </p></dd>
</dl>
</div>
<p>
          <span class="bold"><strong>Header</strong></span>
        </p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><code class="computeroutput"><a class="link" href="reference.html#header.boost.accumulators.statistics.tail_quantile_hpp" title="Header &lt;boost/accumulators/statistics/tail_quantile.hpp&gt;">boost/accumulators/statistics/tail_quantile.hpp</a></code><span class="special">&gt;</span>
</pre>
<p>
          <span class="bold"><strong>Example</strong></span>
        </p>
<pre class="programlisting"><span class="comment">// tolerance in %</span>
<span class="keyword">double</span> <span class="identifier">epsilon</span> <span class="special">=</span> <span class="number">1</span><span class="special">;</span>

<span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">n</span> <span class="special">=</span> <span class="number">100000</span><span class="special">;</span> <span class="comment">// number of MC steps</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">c</span> <span class="special">=</span>  <span class="number">10000</span><span class="special">;</span> <span class="comment">// cache size</span>

<span class="keyword">typedef</span> <span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">tail_quantile</span><span class="special">&lt;</span><span class="identifier">right</span><span class="special">&gt;</span> <span class="special">&gt;</span> <span class="special">&gt;</span> <span class="identifier">accumulator_t_right</span><span class="special">;</span>
<span class="keyword">typedef</span> <span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">tail_quantile</span><span class="special">&lt;</span><span class="identifier">left</span><span class="special">&gt;</span> <span class="special">&gt;</span> <span class="special">&gt;</span> <span class="identifier">accumulator_t_left</span><span class="special">;</span>

<span class="identifier">accumulator_t_right</span> <span class="identifier">acc0</span><span class="special">(</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">tail</span><span class="special">&lt;</span><span class="identifier">right</span><span class="special">&gt;::</span><span class="identifier">cache_size</span> <span class="special">=</span> <span class="identifier">c</span> <span class="special">);</span>
<span class="identifier">accumulator_t_right</span> <span class="identifier">acc1</span><span class="special">(</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">tail</span><span class="special">&lt;</span><span class="identifier">right</span><span class="special">&gt;::</span><span class="identifier">cache_size</span> <span class="special">=</span> <span class="identifier">c</span> <span class="special">);</span>
<span class="identifier">accumulator_t_left</span>  <span class="identifier">acc2</span><span class="special">(</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">tail</span><span class="special">&lt;</span><span class="identifier">left</span><span class="special">&gt;::</span><span class="identifier">cache_size</span> <span class="special">=</span> <span class="identifier">c</span> <span class="special">);</span>
<span class="identifier">accumulator_t_left</span>  <span class="identifier">acc3</span><span class="special">(</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">tail</span><span class="special">&lt;</span><span class="identifier">left</span><span class="special">&gt;::</span><span class="identifier">cache_size</span> <span class="special">=</span> <span class="identifier">c</span> <span class="special">);</span>

<span class="comment">// two random number generators</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">lagged_fibonacci607</span> <span class="identifier">rng</span><span class="special">;</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">normal_distribution</span><span class="special">&lt;&gt;</span> <span class="identifier">mean_sigma</span><span class="special">(</span><span class="number">0</span><span class="special">,</span><span class="number">1</span><span class="special">);</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">variate_generator</span><span class="special">&lt;</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">lagged_fibonacci607</span><span class="special">&amp;,</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">normal_distribution</span><span class="special">&lt;&gt;</span> <span class="special">&gt;</span> <span class="identifier">normal</span><span class="special">(</span><span class="identifier">rng</span><span class="special">,</span> <span class="identifier">mean_sigma</span><span class="special">);</span>

<span class="keyword">for</span> <span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special">&lt;</span> <span class="identifier">n</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
<span class="special">{</span>
    <span class="keyword">double</span> <span class="identifier">sample1</span> <span class="special">=</span> <span class="identifier">rng</span><span class="special">();</span>
    <span class="keyword">double</span> <span class="identifier">sample2</span> <span class="special">=</span> <span class="identifier">normal</span><span class="special">();</span>
    <span class="identifier">acc0</span><span class="special">(</span><span class="identifier">sample1</span><span class="special">);</span>
    <span class="identifier">acc1</span><span class="special">(</span><span class="identifier">sample2</span><span class="special">);</span>
    <span class="identifier">acc2</span><span class="special">(</span><span class="identifier">sample1</span><span class="special">);</span>
    <span class="identifier">acc3</span><span class="special">(</span><span class="identifier">sample2</span><span class="special">);</span>
<span class="special">}</span>

<span class="comment">// check uniform distribution</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">quantile</span><span class="special">(</span><span class="identifier">acc0</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.95</span> <span class="special">),</span> <span class="number">0.95</span><span class="special">,</span>  <span class="identifier">epsilon</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">quantile</span><span class="special">(</span><span class="identifier">acc0</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.975</span><span class="special">),</span> <span class="number">0.975</span><span class="special">,</span> <span class="identifier">epsilon</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">quantile</span><span class="special">(</span><span class="identifier">acc0</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.99</span> <span class="special">),</span> <span class="number">0.99</span><span class="special">,</span>  <span class="identifier">epsilon</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">quantile</span><span class="special">(</span><span class="identifier">acc0</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.999</span><span class="special">),</span> <span class="number">0.999</span><span class="special">,</span> <span class="identifier">epsilon</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">quantile</span><span class="special">(</span><span class="identifier">acc2</span><span class="special">,</span> <span class="identifier">quantile_probability</span>  <span class="special">=</span> <span class="number">0.05</span> <span class="special">),</span> <span class="number">0.05</span><span class="special">,</span>  <span class="number">2</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">quantile</span><span class="special">(</span><span class="identifier">acc2</span><span class="special">,</span> <span class="identifier">quantile_probability</span>  <span class="special">=</span> <span class="number">0.025</span><span class="special">),</span> <span class="number">0.025</span><span class="special">,</span> <span class="number">2</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">quantile</span><span class="special">(</span><span class="identifier">acc2</span><span class="special">,</span> <span class="identifier">quantile_probability</span>  <span class="special">=</span> <span class="number">0.01</span> <span class="special">),</span> <span class="number">0.01</span><span class="special">,</span>  <span class="number">3</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">quantile</span><span class="special">(</span><span class="identifier">acc2</span><span class="special">,</span> <span class="identifier">quantile_probability</span>  <span class="special">=</span> <span class="number">0.001</span><span class="special">),</span> <span class="number">0.001</span><span class="special">,</span> <span class="number">20</span> <span class="special">);</span>

<span class="comment">// check standard normal distribution</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">quantile</span><span class="special">(</span><span class="identifier">acc1</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.975</span><span class="special">),</span>  <span class="number">1.959963</span><span class="special">,</span> <span class="identifier">epsilon</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">quantile</span><span class="special">(</span><span class="identifier">acc1</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.999</span><span class="special">),</span>  <span class="number">3.090232</span><span class="special">,</span> <span class="identifier">epsilon</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">quantile</span><span class="special">(</span><span class="identifier">acc3</span><span class="special">,</span> <span class="identifier">quantile_probability</span>  <span class="special">=</span> <span class="number">0.025</span><span class="special">),</span> <span class="special">-</span><span class="number">1.959963</span><span class="special">,</span> <span class="identifier">epsilon</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">quantile</span><span class="special">(</span><span class="identifier">acc3</span><span class="special">,</span> <span class="identifier">quantile_probability</span>  <span class="special">=</span> <span class="number">0.001</span><span class="special">),</span> <span class="special">-</span><span class="number">3.090232</span><span class="special">,</span> <span class="identifier">epsilon</span> <span class="special">);</span>
</pre>
<p>
          <span class="bold"><strong>See also</strong></span>
        </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
              <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/tail_quantile_impl.html" title="Struct template tail_quantile_impl">tail_quantile_impl</a></code>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.count" title="count"><code class="literal">count</code></a>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.tail" title="tail"><code class="literal">tail</code></a>
            </li>
</ul></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="accumulators.user_s_guide.the_statistical_accumulators_library.tail_variate"></a><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.tail_variate" title="tail_variate">tail_variate</a>
</h4></div></div></div>
<p>
          Tracks the covariates of largest or smallest <code class="literal">N</code> samples.
          <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">tail_variate</span><span class="special">&lt;</span><em class="replaceable"><code>variate-type</code></em><span class="special">,</span> <em class="replaceable"><code>variate-tag</code></em><span class="special">,</span> <span class="identifier">right</span><span class="special">&gt;</span></code> tracks the covariate associated with
          <em class="replaceable"><code>variate-tag</code></em> for the largest <code class="literal">N</code>, and <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">tail_variate</span><span class="special">&lt;</span><em class="replaceable"><code>variate-type</code></em><span class="special">,</span> <em class="replaceable"><code>variate-tag</code></em><span class="special">,</span>
          <span class="identifier">left</span><span class="special">&gt;</span></code>
          for the smallest. The parameter <code class="literal">N</code> is specified with
          the <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">tail</span><span class="special">&lt;</span><em class="replaceable"><code>left-or-right</code></em><span class="special">&gt;::</span><span class="identifier">cache_size</span></code>
          initialization parameter. For implementation details, see <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/tail_variate_impl.html" title="Struct template tail_variate_impl">tail_variate_impl</a></code>.
        </p>
<p>
          Both <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">tail_variate</span><span class="special">&lt;</span><em class="replaceable"><code>variate-type</code></em><span class="special">,</span> <em class="replaceable"><code>variate-tag</code></em><span class="special">,</span> <span class="identifier">right</span><span class="special">&gt;</span></code> and <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">tail_variate</span><span class="special">&lt;</span><em class="replaceable"><code>variate-type</code></em><span class="special">,</span> <em class="replaceable"><code>variate-tag</code></em><span class="special">,</span>
          <span class="identifier">left</span><span class="special">&gt;</span></code>
          satisfy the <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">abstract_tail_variate</span></code> feature and can
          be extracted with the <code class="computeroutput"><span class="identifier">tail_variate</span><span class="special">()</span></code> extractor.
        </p>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Result Type</span></dt>
<dd>
<p>
</p>
<pre class="programlisting"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">iterator_range</span><span class="special">&lt;</span>
    <span class="identifier">boost</span><span class="special">::</span><span class="identifier">reverse_iterator</span><span class="special">&lt;</span>
        <span class="identifier">boost</span><span class="special">::</span><span class="identifier">permutation_iterator</span><span class="special">&lt;</span>
            <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span><em class="replaceable"><code>variate-type</code></em><span class="special">&gt;::</span><span class="identifier">const_iterator</span> <span class="comment">// variates</span>
          <span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">&gt;::</span><span class="identifier">iterator</span>          <span class="comment">// indices</span>
        <span class="special">&gt;</span>
    <span class="special">&gt;</span>
<span class="special">&gt;</span>
</pre>
<p>
              </p>
</dd>
<dt><span class="term">Depends On</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">tail</span><span class="special">&lt;</span><em class="replaceable"><code>left-or-right</code></em><span class="special">&gt;</span></code>
              </p></dd>
<dt><span class="term">Variants</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">abstract_tail_variate</span></code>
              </p></dd>
<dt><span class="term">Initialization Parameters</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">tail</span><span class="special">&lt;</span><em class="replaceable"><code>left-or-right</code></em><span class="special">&gt;::</span><span class="identifier">cache_size</span></code>
              </p></dd>
<dt><span class="term">Accumulator Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Extractor Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Accumulator Complexity</span></dt>
<dd><p>
                O(log N), where N is the cache size
              </p></dd>
<dt><span class="term">Extractor Complexity</span></dt>
<dd><p>
                O(N log N), where N is the cache size
              </p></dd>
</dl>
</div>
<p>
          <span class="bold"><strong>Header</strong></span>
        </p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><code class="computeroutput"><a class="link" href="reference.html#header.boost.accumulators.statistics.tail_variate_hpp" title="Header &lt;boost/accumulators/statistics/tail_variate.hpp&gt;">boost/accumulators/statistics/tail_variate.hpp</a></code><span class="special">&gt;</span>
</pre>
<p>
          <span class="bold"><strong>Example</strong></span>
        </p>
<pre class="programlisting"><span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">tail_variate</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">,</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">covariate1</span><span class="special">,</span> <span class="identifier">right</span><span class="special">&gt;</span> <span class="special">&gt;</span> <span class="special">&gt;</span> <span class="identifier">acc</span><span class="special">(</span>
    <span class="identifier">tag</span><span class="special">::</span><span class="identifier">tail</span><span class="special">&lt;</span><span class="identifier">right</span><span class="special">&gt;::</span><span class="identifier">cache_size</span> <span class="special">=</span> <span class="number">4</span>
<span class="special">);</span>

<span class="identifier">acc</span><span class="special">(</span><span class="number">8</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="number">3</span><span class="special">);</span>
<span class="identifier">CHECK_RANGE_EQUAL</span><span class="special">(</span><span class="identifier">tail</span><span class="special">(</span><span class="identifier">acc</span><span class="special">),</span> <span class="special">{</span><span class="number">8</span><span class="special">});</span>
<span class="identifier">CHECK_RANGE_EQUAL</span><span class="special">(</span><span class="identifier">tail_variate</span><span class="special">(</span><span class="identifier">acc</span><span class="special">),</span> <span class="special">{</span><span class="number">3</span><span class="special">});</span>

<span class="identifier">acc</span><span class="special">(</span><span class="number">16</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="number">1</span><span class="special">);</span>
<span class="identifier">CHECK_RANGE_EQUAL</span><span class="special">(</span><span class="identifier">tail</span><span class="special">(</span><span class="identifier">acc</span><span class="special">),</span> <span class="special">{</span><span class="number">16</span><span class="special">,</span> <span class="number">8</span><span class="special">});</span>
<span class="identifier">CHECK_RANGE_EQUAL</span><span class="special">(</span><span class="identifier">tail_variate</span><span class="special">(</span><span class="identifier">acc</span><span class="special">),</span> <span class="special">{</span><span class="number">1</span><span class="special">,</span> <span class="number">3</span><span class="special">});</span>

<span class="identifier">acc</span><span class="special">(</span><span class="number">12</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="number">4</span><span class="special">);</span>
<span class="identifier">CHECK_RANGE_EQUAL</span><span class="special">(</span><span class="identifier">tail</span><span class="special">(</span><span class="identifier">acc</span><span class="special">),</span> <span class="special">{</span><span class="number">16</span><span class="special">,</span> <span class="number">12</span><span class="special">,</span> <span class="number">8</span><span class="special">});</span>
<span class="identifier">CHECK_RANGE_EQUAL</span><span class="special">(</span><span class="identifier">tail_variate</span><span class="special">(</span><span class="identifier">acc</span><span class="special">),</span> <span class="special">{</span><span class="number">1</span><span class="special">,</span> <span class="number">4</span><span class="special">,</span> <span class="number">3</span><span class="special">});</span>

<span class="identifier">acc</span><span class="special">(</span><span class="number">24</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="number">5</span><span class="special">);</span>
<span class="identifier">CHECK_RANGE_EQUAL</span><span class="special">(</span><span class="identifier">tail</span><span class="special">(</span><span class="identifier">acc</span><span class="special">),</span> <span class="special">{</span><span class="number">24</span><span class="special">,</span> <span class="number">16</span><span class="special">,</span> <span class="number">12</span><span class="special">,</span> <span class="number">8</span><span class="special">});</span>
<span class="identifier">CHECK_RANGE_EQUAL</span><span class="special">(</span><span class="identifier">tail_variate</span><span class="special">(</span><span class="identifier">acc</span><span class="special">),</span> <span class="special">{</span><span class="number">5</span><span class="special">,</span> <span class="number">1</span><span class="special">,</span> <span class="number">4</span><span class="special">,</span> <span class="number">3</span><span class="special">});</span>

<span class="identifier">acc</span><span class="special">(</span><span class="number">1</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="number">9</span><span class="special">);</span>
<span class="identifier">CHECK_RANGE_EQUAL</span><span class="special">(</span><span class="identifier">tail</span><span class="special">(</span><span class="identifier">acc</span><span class="special">),</span> <span class="special">{</span><span class="number">24</span><span class="special">,</span> <span class="number">16</span><span class="special">,</span> <span class="number">12</span><span class="special">,</span> <span class="number">8</span><span class="special">});</span>
<span class="identifier">CHECK_RANGE_EQUAL</span><span class="special">(</span><span class="identifier">tail_variate</span><span class="special">(</span><span class="identifier">acc</span><span class="special">),</span> <span class="special">{</span><span class="number">5</span><span class="special">,</span> <span class="number">1</span><span class="special">,</span> <span class="number">4</span><span class="special">,</span> <span class="number">3</span><span class="special">});</span>

<span class="identifier">acc</span><span class="special">(</span><span class="number">9</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="number">7</span><span class="special">);</span>
<span class="identifier">CHECK_RANGE_EQUAL</span><span class="special">(</span><span class="identifier">tail</span><span class="special">(</span><span class="identifier">acc</span><span class="special">),</span> <span class="special">{</span><span class="number">24</span><span class="special">,</span>  <span class="number">16</span><span class="special">,</span> <span class="number">12</span><span class="special">,</span> <span class="number">9</span><span class="special">});</span>
<span class="identifier">CHECK_RANGE_EQUAL</span><span class="special">(</span><span class="identifier">tail_variate</span><span class="special">(</span><span class="identifier">acc</span><span class="special">),</span> <span class="special">{</span><span class="number">5</span><span class="special">,</span> <span class="number">1</span><span class="special">,</span> <span class="number">4</span><span class="special">,</span> <span class="number">7</span><span class="special">});</span>
</pre>
<p>
          <span class="bold"><strong>See also</strong></span>
        </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
              <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/tail_variate_impl.html" title="Struct template tail_variate_impl">tail_variate_impl</a></code>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.tail" title="tail"><code class="literal">tail</code></a>
            </li>
</ul></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="accumulators.user_s_guide.the_statistical_accumulators_library.tail_variate_means"></a><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.tail_variate_means" title="tail_variate_means and variants">tail_variate_means
        <span class="emphasis"><em>and variants</em></span></a>
</h4></div></div></div>
<p>
          Estimation of the absolute and relative tail variate means (for both left
          and right tails). The absolute tail variate means has the feature <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">absolute_tail_variate_means</span><span class="special">&lt;</span><em class="replaceable"><code>left-or-right</code></em><span class="special">,</span> <em class="replaceable"><code>variate-type</code></em><span class="special">,</span> <em class="replaceable"><code>variate-tag</code></em><span class="special">&gt;</span></code>
          and the relative tail variate mean has the feature <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">relative_tail_variate_means</span><span class="special">&lt;</span><em class="replaceable"><code>left-or-right</code></em><span class="special">,</span> <em class="replaceable"><code>variate-type</code></em><span class="special">,</span>
          <em class="replaceable"><code>variate-tag</code></em><span class="special">&gt;</span></code>. All absolute tail variate
          mean features share the <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">abstract_absolute_tail_variate_means</span></code>
          feature and can be extracted with the <code class="computeroutput"><span class="identifier">tail_variate_means</span><span class="special">()</span></code> extractor. All the relative tail variate
          mean features share the <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">abstract_relative_tail_variate_means</span></code>
          feature and can be extracted with the <code class="computeroutput"><span class="identifier">relative_tail_variate_means</span><span class="special">()</span></code> extractor.
        </p>
<p>
          For more implementation details, see <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/tail_variate_means_impl.html" title="Struct template tail_variate_means_impl">tail_variate_means_impl</a></code>
        </p>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Result Type</span></dt>
<dd>
<p>
</p>
<pre class="programlisting"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">iterator_range</span><span class="special">&lt;</span>
    <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span>
        <span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">fdiv</span><span class="special">&lt;</span><em class="replaceable"><code>sample-type</code></em><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">&gt;::</span><span class="identifier">result_type</span>
    <span class="special">&gt;::</span><span class="identifier">iterator</span>
<span class="special">&gt;</span>
</pre>
<p>
              </p>
</dd>
<dt><span class="term">Depends On</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">non_coherent_tail_mean</span><span class="special">&lt;</span><em class="replaceable"><code>left-or-right</code></em><span class="special">&gt;</span></code>
                <br> <code class="computeroutput"><span class="identifier">tail_variate</span><span class="special">&lt;</span><em class="replaceable"><code>variate-type</code></em><span class="special">,</span> <em class="replaceable"><code>variate-tag</code></em><span class="special">,</span> <em class="replaceable"><code>left-or-right</code></em><span class="special">&gt;</span></code>
              </p></dd>
<dt><span class="term">Variants</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">absolute_tail_variate_means</span><span class="special">&lt;</span><em class="replaceable"><code>left-or-right</code></em><span class="special">,</span> <em class="replaceable"><code>variate-type</code></em><span class="special">,</span> <em class="replaceable"><code>variate-tag</code></em><span class="special">&gt;</span></code> <br> <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">relative_tail_variate_means</span><span class="special">&lt;</span><em class="replaceable"><code>left-or-right</code></em><span class="special">,</span> <em class="replaceable"><code>variate-type</code></em><span class="special">,</span> <em class="replaceable"><code>variate-tag</code></em><span class="special">&gt;</span></code>
              </p></dd>
<dt><span class="term">Initialization Parameters</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">tail</span><span class="special">&lt;</span><em class="replaceable"><code>left-or-right</code></em><span class="special">&gt;::</span><span class="identifier">cache_size</span></code>
              </p></dd>
<dt><span class="term">Accumulator Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Extractor Parameters</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">quantile_probability</span></code>
              </p></dd>
<dt><span class="term">Accumulator Complexity</span></dt>
<dd><p>
                O(log N), where N is the cache size
              </p></dd>
<dt><span class="term">Extractor Complexity</span></dt>
<dd><p>
                O(N log N), where N is the cache size
              </p></dd>
</dl>
</div>
<p>
          <span class="bold"><strong>Header</strong></span>
        </p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><code class="computeroutput"><a class="link" href="reference.html#header.boost.accumulators.statistics.tail_variate_means_hpp" title="Header &lt;boost/accumulators/statistics/tail_variate_means.hpp&gt;">boost/accumulators/statistics/tail_variate_means.hpp</a></code><span class="special">&gt;</span>
</pre>
<p>
          <span class="bold"><strong>Example</strong></span>
        </p>
<pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">c</span> <span class="special">=</span> <span class="number">5</span><span class="special">;</span> <span class="comment">// cache size</span>

<span class="keyword">typedef</span> <span class="keyword">double</span> <span class="identifier">variate_type</span><span class="special">;</span>
<span class="keyword">typedef</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span><span class="identifier">variate_type</span><span class="special">&gt;</span> <span class="identifier">variate_set_type</span><span class="special">;</span>

<span class="keyword">typedef</span> <span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span>
    <span class="identifier">tag</span><span class="special">::</span><span class="identifier">tail_variate_means</span><span class="special">&lt;</span><span class="identifier">right</span><span class="special">,</span> <span class="identifier">variate_set_type</span><span class="special">,</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">covariate1</span><span class="special">&gt;(</span><span class="identifier">relative</span><span class="special">)&gt;,</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">tail</span><span class="special">&lt;</span><span class="identifier">right</span><span class="special">&gt;</span> <span class="special">&gt;</span>
<span class="identifier">accumulator_t1</span><span class="special">;</span>

<span class="keyword">typedef</span> <span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span>
    <span class="identifier">tag</span><span class="special">::</span><span class="identifier">tail_variate_means</span><span class="special">&lt;</span><span class="identifier">right</span><span class="special">,</span> <span class="identifier">variate_set_type</span><span class="special">,</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">covariate1</span><span class="special">&gt;(</span><span class="identifier">absolute</span><span class="special">)&gt;,</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">tail</span><span class="special">&lt;</span><span class="identifier">right</span><span class="special">&gt;</span> <span class="special">&gt;</span>
<span class="identifier">accumulator_t2</span><span class="special">;</span>

<span class="keyword">typedef</span> <span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span>
    <span class="identifier">tag</span><span class="special">::</span><span class="identifier">tail_variate_means</span><span class="special">&lt;</span><span class="identifier">left</span><span class="special">,</span> <span class="identifier">variate_set_type</span><span class="special">,</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">covariate1</span><span class="special">&gt;(</span><span class="identifier">relative</span><span class="special">)&gt;,</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">tail</span><span class="special">&lt;</span><span class="identifier">left</span><span class="special">&gt;</span> <span class="special">&gt;</span>
<span class="identifier">accumulator_t3</span><span class="special">;</span>

<span class="keyword">typedef</span> <span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span>
    <span class="identifier">tag</span><span class="special">::</span><span class="identifier">tail_variate_means</span><span class="special">&lt;</span><span class="identifier">left</span><span class="special">,</span> <span class="identifier">variate_set_type</span><span class="special">,</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">covariate1</span><span class="special">&gt;(</span><span class="identifier">absolute</span><span class="special">)&gt;,</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">tail</span><span class="special">&lt;</span><span class="identifier">left</span><span class="special">&gt;</span> <span class="special">&gt;</span>
<span class="identifier">accumulator_t4</span><span class="special">;</span>

<span class="identifier">accumulator_t1</span> <span class="identifier">acc1</span><span class="special">(</span> <span class="identifier">right_tail_cache_size</span> <span class="special">=</span> <span class="identifier">c</span> <span class="special">);</span>
<span class="identifier">accumulator_t2</span> <span class="identifier">acc2</span><span class="special">(</span> <span class="identifier">right_tail_cache_size</span> <span class="special">=</span> <span class="identifier">c</span> <span class="special">);</span>
<span class="identifier">accumulator_t3</span> <span class="identifier">acc3</span><span class="special">(</span> <span class="identifier">left_tail_cache_size</span> <span class="special">=</span> <span class="identifier">c</span> <span class="special">);</span>
<span class="identifier">accumulator_t4</span> <span class="identifier">acc4</span><span class="special">(</span> <span class="identifier">left_tail_cache_size</span> <span class="special">=</span> <span class="identifier">c</span> <span class="special">);</span>

<span class="identifier">variate_set_type</span> <span class="identifier">cov1</span><span class="special">,</span> <span class="identifier">cov2</span><span class="special">,</span> <span class="identifier">cov3</span><span class="special">,</span> <span class="identifier">cov4</span><span class="special">,</span> <span class="identifier">cov5</span><span class="special">;</span>
<span class="keyword">double</span> <span class="identifier">c1</span><span class="special">[]</span> <span class="special">=</span> <span class="special">{</span> <span class="number">10.</span><span class="special">,</span> <span class="number">20.</span><span class="special">,</span> <span class="number">30.</span><span class="special">,</span> <span class="number">40.</span> <span class="special">};</span> <span class="comment">// 100</span>
<span class="keyword">double</span> <span class="identifier">c2</span><span class="special">[]</span> <span class="special">=</span> <span class="special">{</span> <span class="number">26.</span><span class="special">,</span>  <span class="number">4.</span><span class="special">,</span> <span class="number">17.</span><span class="special">,</span>  <span class="number">3.</span> <span class="special">};</span> <span class="comment">// 50</span>
<span class="keyword">double</span> <span class="identifier">c3</span><span class="special">[]</span> <span class="special">=</span> <span class="special">{</span> <span class="number">46.</span><span class="special">,</span> <span class="number">64.</span><span class="special">,</span> <span class="number">40.</span><span class="special">,</span> <span class="number">50.</span> <span class="special">};</span> <span class="comment">// 200</span>
<span class="keyword">double</span> <span class="identifier">c4</span><span class="special">[]</span> <span class="special">=</span> <span class="special">{</span>  <span class="number">1.</span><span class="special">,</span>  <span class="number">3.</span><span class="special">,</span> <span class="number">70.</span><span class="special">,</span>  <span class="number">6.</span> <span class="special">};</span> <span class="comment">// 80</span>
<span class="keyword">double</span> <span class="identifier">c5</span><span class="special">[]</span> <span class="special">=</span> <span class="special">{</span>  <span class="number">2.</span><span class="special">,</span>  <span class="number">2.</span><span class="special">,</span>  <span class="number">2.</span><span class="special">,</span> <span class="number">14.</span> <span class="special">};</span> <span class="comment">// 20</span>
<span class="identifier">cov1</span><span class="special">.</span><span class="identifier">assign</span><span class="special">(</span><span class="identifier">c1</span><span class="special">,</span> <span class="identifier">c1</span> <span class="special">+</span> <span class="keyword">sizeof</span><span class="special">(</span><span class="identifier">c1</span><span class="special">)/</span><span class="keyword">sizeof</span><span class="special">(</span><span class="identifier">variate_type</span><span class="special">));</span>
<span class="identifier">cov2</span><span class="special">.</span><span class="identifier">assign</span><span class="special">(</span><span class="identifier">c2</span><span class="special">,</span> <span class="identifier">c2</span> <span class="special">+</span> <span class="keyword">sizeof</span><span class="special">(</span><span class="identifier">c2</span><span class="special">)/</span><span class="keyword">sizeof</span><span class="special">(</span><span class="identifier">variate_type</span><span class="special">));</span>
<span class="identifier">cov3</span><span class="special">.</span><span class="identifier">assign</span><span class="special">(</span><span class="identifier">c3</span><span class="special">,</span> <span class="identifier">c3</span> <span class="special">+</span> <span class="keyword">sizeof</span><span class="special">(</span><span class="identifier">c3</span><span class="special">)/</span><span class="keyword">sizeof</span><span class="special">(</span><span class="identifier">variate_type</span><span class="special">));</span>
<span class="identifier">cov4</span><span class="special">.</span><span class="identifier">assign</span><span class="special">(</span><span class="identifier">c4</span><span class="special">,</span> <span class="identifier">c4</span> <span class="special">+</span> <span class="keyword">sizeof</span><span class="special">(</span><span class="identifier">c4</span><span class="special">)/</span><span class="keyword">sizeof</span><span class="special">(</span><span class="identifier">variate_type</span><span class="special">));</span>
<span class="identifier">cov5</span><span class="special">.</span><span class="identifier">assign</span><span class="special">(</span><span class="identifier">c5</span><span class="special">,</span> <span class="identifier">c5</span> <span class="special">+</span> <span class="keyword">sizeof</span><span class="special">(</span><span class="identifier">c5</span><span class="special">)/</span><span class="keyword">sizeof</span><span class="special">(</span><span class="identifier">variate_type</span><span class="special">));</span>

<span class="identifier">acc1</span><span class="special">(</span><span class="number">100.</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="identifier">cov1</span><span class="special">);</span>
<span class="identifier">acc1</span><span class="special">(</span> <span class="number">50.</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="identifier">cov2</span><span class="special">);</span>
<span class="identifier">acc1</span><span class="special">(</span><span class="number">200.</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="identifier">cov3</span><span class="special">);</span>
<span class="identifier">acc1</span><span class="special">(</span> <span class="number">80.</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="identifier">cov4</span><span class="special">);</span>
<span class="identifier">acc1</span><span class="special">(</span> <span class="number">20.</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="identifier">cov5</span><span class="special">);</span>

<span class="identifier">acc2</span><span class="special">(</span><span class="number">100.</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="identifier">cov1</span><span class="special">);</span>
<span class="identifier">acc2</span><span class="special">(</span> <span class="number">50.</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="identifier">cov2</span><span class="special">);</span>
<span class="identifier">acc2</span><span class="special">(</span><span class="number">200.</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="identifier">cov3</span><span class="special">);</span>
<span class="identifier">acc2</span><span class="special">(</span> <span class="number">80.</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="identifier">cov4</span><span class="special">);</span>
<span class="identifier">acc2</span><span class="special">(</span> <span class="number">20.</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="identifier">cov5</span><span class="special">);</span>

<span class="identifier">acc3</span><span class="special">(</span><span class="number">100.</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="identifier">cov1</span><span class="special">);</span>
<span class="identifier">acc3</span><span class="special">(</span> <span class="number">50.</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="identifier">cov2</span><span class="special">);</span>
<span class="identifier">acc3</span><span class="special">(</span><span class="number">200.</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="identifier">cov3</span><span class="special">);</span>
<span class="identifier">acc3</span><span class="special">(</span> <span class="number">80.</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="identifier">cov4</span><span class="special">);</span>
<span class="identifier">acc3</span><span class="special">(</span> <span class="number">20.</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="identifier">cov5</span><span class="special">);</span>

<span class="identifier">acc4</span><span class="special">(</span><span class="number">100.</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="identifier">cov1</span><span class="special">);</span>
<span class="identifier">acc4</span><span class="special">(</span> <span class="number">50.</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="identifier">cov2</span><span class="special">);</span>
<span class="identifier">acc4</span><span class="special">(</span><span class="number">200.</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="identifier">cov3</span><span class="special">);</span>
<span class="identifier">acc4</span><span class="special">(</span> <span class="number">80.</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="identifier">cov4</span><span class="special">);</span>
<span class="identifier">acc4</span><span class="special">(</span> <span class="number">20.</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="identifier">cov5</span><span class="special">);</span>

<span class="comment">// check relative risk contributions</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="special">*(</span><span class="identifier">relative_tail_variate_means</span><span class="special">(</span><span class="identifier">acc1</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.7</span><span class="special">).</span><span class="identifier">begin</span><span class="special">()</span>     <span class="special">),</span> <span class="number">14.</span><span class="special">/</span><span class="number">75.</span> <span class="special">);</span> <span class="comment">// (10 + 46) / 300 = 14/75</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="special">*(</span><span class="identifier">relative_tail_variate_means</span><span class="special">(</span><span class="identifier">acc1</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.7</span><span class="special">).</span><span class="identifier">begin</span><span class="special">()</span> <span class="special">+</span> <span class="number">1</span><span class="special">),</span>  <span class="number">7.</span><span class="special">/</span><span class="number">25.</span> <span class="special">);</span> <span class="comment">// (20 + 64) / 300 =  7/25</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="special">*(</span><span class="identifier">relative_tail_variate_means</span><span class="special">(</span><span class="identifier">acc1</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.7</span><span class="special">).</span><span class="identifier">begin</span><span class="special">()</span> <span class="special">+</span> <span class="number">2</span><span class="special">),</span>  <span class="number">7.</span><span class="special">/</span><span class="number">30.</span> <span class="special">);</span> <span class="comment">// (30 + 40) / 300 =  7/30</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="special">*(</span><span class="identifier">relative_tail_variate_means</span><span class="special">(</span><span class="identifier">acc1</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.7</span><span class="special">).</span><span class="identifier">begin</span><span class="special">()</span> <span class="special">+</span> <span class="number">3</span><span class="special">),</span>  <span class="number">3.</span><span class="special">/</span><span class="number">10.</span> <span class="special">);</span> <span class="comment">// (40 + 50) / 300 =  3/10</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="special">*(</span><span class="identifier">relative_tail_variate_means</span><span class="special">(</span><span class="identifier">acc3</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.3</span><span class="special">).</span><span class="identifier">begin</span><span class="special">()</span>    <span class="special">),</span> <span class="number">14.</span><span class="special">/</span><span class="number">35.</span> <span class="special">);</span> <span class="comment">// (26 +  2) /  70 = 14/35</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="special">*(</span><span class="identifier">relative_tail_variate_means</span><span class="special">(</span><span class="identifier">acc3</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.3</span><span class="special">).</span><span class="identifier">begin</span><span class="special">()</span> <span class="special">+</span> <span class="number">1</span><span class="special">),</span>  <span class="number">3.</span><span class="special">/</span><span class="number">35.</span> <span class="special">);</span> <span class="comment">// ( 4 +  2) /  70 =  3/35</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="special">*(</span><span class="identifier">relative_tail_variate_means</span><span class="special">(</span><span class="identifier">acc3</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.3</span><span class="special">).</span><span class="identifier">begin</span><span class="special">()</span> <span class="special">+</span> <span class="number">2</span><span class="special">),</span> <span class="number">19.</span><span class="special">/</span><span class="number">70.</span> <span class="special">);</span> <span class="comment">// (17 +  2) /  70 = 19/70</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="special">*(</span><span class="identifier">relative_tail_variate_means</span><span class="special">(</span><span class="identifier">acc3</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.3</span><span class="special">).</span><span class="identifier">begin</span><span class="special">()</span> <span class="special">+</span> <span class="number">3</span><span class="special">),</span> <span class="number">17.</span><span class="special">/</span><span class="number">70.</span> <span class="special">);</span> <span class="comment">// ( 3 + 14) /  70 = 17/70</span>

<span class="comment">// check absolute risk contributions</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="special">*(</span><span class="identifier">tail_variate_means</span><span class="special">(</span><span class="identifier">acc2</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.7</span><span class="special">).</span><span class="identifier">begin</span><span class="special">()</span>    <span class="special">),</span> <span class="number">28</span> <span class="special">);</span> <span class="comment">// (10 + 46) / 2 = 28</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="special">*(</span><span class="identifier">tail_variate_means</span><span class="special">(</span><span class="identifier">acc2</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.7</span><span class="special">).</span><span class="identifier">begin</span><span class="special">()</span> <span class="special">+</span> <span class="number">1</span><span class="special">),</span> <span class="number">42</span> <span class="special">);</span> <span class="comment">// (20 + 64) / 2 = 42</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="special">*(</span><span class="identifier">tail_variate_means</span><span class="special">(</span><span class="identifier">acc2</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.7</span><span class="special">).</span><span class="identifier">begin</span><span class="special">()</span> <span class="special">+</span> <span class="number">2</span><span class="special">),</span> <span class="number">35</span> <span class="special">);</span> <span class="comment">// (30 + 40) / 2 = 35</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="special">*(</span><span class="identifier">tail_variate_means</span><span class="special">(</span><span class="identifier">acc2</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.7</span><span class="special">).</span><span class="identifier">begin</span><span class="special">()</span> <span class="special">+</span> <span class="number">3</span><span class="special">),</span> <span class="number">45</span> <span class="special">);</span> <span class="comment">// (40 + 50) / 2 = 45</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="special">*(</span><span class="identifier">tail_variate_means</span><span class="special">(</span><span class="identifier">acc4</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.3</span><span class="special">).</span><span class="identifier">begin</span><span class="special">()</span>    <span class="special">),</span> <span class="number">14</span> <span class="special">);</span> <span class="comment">// (26 +  2) / 2 = 14</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="special">*(</span><span class="identifier">tail_variate_means</span><span class="special">(</span><span class="identifier">acc4</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.3</span><span class="special">).</span><span class="identifier">begin</span><span class="special">()</span> <span class="special">+</span> <span class="number">1</span><span class="special">),</span>  <span class="number">3</span> <span class="special">);</span> <span class="comment">// ( 4 +  2) / 2 =  3</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="special">*(</span><span class="identifier">tail_variate_means</span><span class="special">(</span><span class="identifier">acc4</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.3</span><span class="special">).</span><span class="identifier">begin</span><span class="special">()</span> <span class="special">+</span> <span class="number">2</span><span class="special">),</span><span class="number">9.5</span> <span class="special">);</span> <span class="comment">// (17 +  2) / 2 =  9.5</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="special">*(</span><span class="identifier">tail_variate_means</span><span class="special">(</span><span class="identifier">acc4</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.3</span><span class="special">).</span><span class="identifier">begin</span><span class="special">()</span> <span class="special">+</span> <span class="number">3</span><span class="special">),</span><span class="number">8.5</span> <span class="special">);</span> <span class="comment">// ( 3 + 14) / 2 =  8.5</span>

<span class="comment">// check relative risk contributions</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="special">*(</span><span class="identifier">relative_tail_variate_means</span><span class="special">(</span><span class="identifier">acc1</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.9</span><span class="special">).</span><span class="identifier">begin</span><span class="special">()</span>    <span class="special">),</span> <span class="number">23.</span><span class="special">/</span><span class="number">100.</span> <span class="special">);</span> <span class="comment">// 46/200 = 23/100</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="special">*(</span><span class="identifier">relative_tail_variate_means</span><span class="special">(</span><span class="identifier">acc1</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.9</span><span class="special">).</span><span class="identifier">begin</span><span class="special">()</span> <span class="special">+</span> <span class="number">1</span><span class="special">),</span>  <span class="number">8.</span><span class="special">/</span><span class="number">25.</span>  <span class="special">);</span> <span class="comment">// 64/200 =  8/25</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="special">*(</span><span class="identifier">relative_tail_variate_means</span><span class="special">(</span><span class="identifier">acc1</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.9</span><span class="special">).</span><span class="identifier">begin</span><span class="special">()</span> <span class="special">+</span> <span class="number">2</span><span class="special">),</span>  <span class="number">1.</span><span class="special">/</span><span class="number">5.</span>   <span class="special">);</span> <span class="comment">// 40/200 =  1/5</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="special">*(</span><span class="identifier">relative_tail_variate_means</span><span class="special">(</span><span class="identifier">acc1</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.9</span><span class="special">).</span><span class="identifier">begin</span><span class="special">()</span> <span class="special">+</span> <span class="number">3</span><span class="special">),</span>  <span class="number">1.</span><span class="special">/</span><span class="number">4.</span>   <span class="special">);</span> <span class="comment">// 50/200 =  1/4</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="special">*(</span><span class="identifier">relative_tail_variate_means</span><span class="special">(</span><span class="identifier">acc3</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.1</span><span class="special">).</span><span class="identifier">begin</span><span class="special">()</span>    <span class="special">),</span>  <span class="number">1.</span><span class="special">/</span><span class="number">10.</span>  <span class="special">);</span> <span class="comment">//  2/ 20 =  1/10</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="special">*(</span><span class="identifier">relative_tail_variate_means</span><span class="special">(</span><span class="identifier">acc3</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.1</span><span class="special">).</span><span class="identifier">begin</span><span class="special">()</span> <span class="special">+</span> <span class="number">1</span><span class="special">),</span>  <span class="number">1.</span><span class="special">/</span><span class="number">10.</span>  <span class="special">);</span> <span class="comment">//  2/ 20 =  1/10</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="special">*(</span><span class="identifier">relative_tail_variate_means</span><span class="special">(</span><span class="identifier">acc3</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.1</span><span class="special">).</span><span class="identifier">begin</span><span class="special">()</span> <span class="special">+</span> <span class="number">2</span><span class="special">),</span>  <span class="number">1.</span><span class="special">/</span><span class="number">10.</span>  <span class="special">);</span> <span class="comment">//  2/ 20 =  1/10</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="special">*(</span><span class="identifier">relative_tail_variate_means</span><span class="special">(</span><span class="identifier">acc3</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.1</span><span class="special">).</span><span class="identifier">begin</span><span class="special">()</span> <span class="special">+</span> <span class="number">3</span><span class="special">),</span>  <span class="number">7.</span><span class="special">/</span><span class="number">10.</span>  <span class="special">);</span> <span class="comment">// 14/ 20 =  7/10</span>

<span class="comment">// check absolute risk contributions</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="special">*(</span><span class="identifier">tail_variate_means</span><span class="special">(</span><span class="identifier">acc2</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.9</span><span class="special">).</span><span class="identifier">begin</span><span class="special">()</span>    <span class="special">),</span> <span class="number">46</span> <span class="special">);</span> <span class="comment">// 46</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="special">*(</span><span class="identifier">tail_variate_means</span><span class="special">(</span><span class="identifier">acc2</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.9</span><span class="special">).</span><span class="identifier">begin</span><span class="special">()</span> <span class="special">+</span> <span class="number">1</span><span class="special">),</span> <span class="number">64</span> <span class="special">);</span> <span class="comment">// 64</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="special">*(</span><span class="identifier">tail_variate_means</span><span class="special">(</span><span class="identifier">acc2</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.9</span><span class="special">).</span><span class="identifier">begin</span><span class="special">()</span> <span class="special">+</span> <span class="number">2</span><span class="special">),</span> <span class="number">40</span> <span class="special">);</span> <span class="comment">// 40</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="special">*(</span><span class="identifier">tail_variate_means</span><span class="special">(</span><span class="identifier">acc2</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.9</span><span class="special">).</span><span class="identifier">begin</span><span class="special">()</span> <span class="special">+</span> <span class="number">3</span><span class="special">),</span> <span class="number">50</span> <span class="special">);</span> <span class="comment">// 50</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="special">*(</span><span class="identifier">tail_variate_means</span><span class="special">(</span><span class="identifier">acc4</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.1</span><span class="special">).</span><span class="identifier">begin</span><span class="special">()</span>    <span class="special">),</span>  <span class="number">2</span> <span class="special">);</span> <span class="comment">//  2</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="special">*(</span><span class="identifier">tail_variate_means</span><span class="special">(</span><span class="identifier">acc4</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.1</span><span class="special">).</span><span class="identifier">begin</span><span class="special">()</span> <span class="special">+</span> <span class="number">1</span><span class="special">),</span>  <span class="number">2</span> <span class="special">);</span> <span class="comment">//  2</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="special">*(</span><span class="identifier">tail_variate_means</span><span class="special">(</span><span class="identifier">acc4</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.1</span><span class="special">).</span><span class="identifier">begin</span><span class="special">()</span> <span class="special">+</span> <span class="number">2</span><span class="special">),</span>  <span class="number">2</span> <span class="special">);</span> <span class="comment">//  2</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="special">*(</span><span class="identifier">tail_variate_means</span><span class="special">(</span><span class="identifier">acc4</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.1</span><span class="special">).</span><span class="identifier">begin</span><span class="special">()</span> <span class="special">+</span> <span class="number">3</span><span class="special">),</span> <span class="number">14</span> <span class="special">);</span> <span class="comment">// 14</span>
</pre>
<p>
          <span class="bold"><strong>See also</strong></span>
        </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
              <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/tail_variate_means_impl.html" title="Struct template tail_variate_means_impl">tail_variate_means_impl</a></code>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.non_coherent_tail_mean" title="non_coherent_tail_mean"><code class="literal">non_coherent_tail_mean</code></a>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.tail_variate" title="tail_variate"><code class="literal">tail_variate</code></a>
            </li>
</ul></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="accumulators.user_s_guide.the_statistical_accumulators_library.variance"></a><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.variance" title="variance and variants">variance
        <span class="emphasis"><em>and variants</em></span></a>
</h4></div></div></div>
<p>
          Lazy or iterative calculation of the variance. The lazy calculation is
          associated with the <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">lazy_variance</span></code>
          feature, and the iterative calculation with the <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">variance</span></code>
          feature. Both can be extracted using the <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">variance</span><span class="special">()</span></code> extractor. For more implementation details,
          see <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/lazy_variance_impl.html" title="Struct template lazy_variance_impl">lazy_variance_impl</a></code>
          and <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/variance_impl.html" title="Struct template variance_impl">variance_impl</a></code>
        </p>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Result Type</span></dt>
<dd>
<p>
</p>
<pre class="programlisting"><span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">fdiv</span><span class="special">&lt;</span><em class="replaceable"><code>sample-type</code></em><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">&gt;::</span><span class="identifier">result_type</span>
</pre>
<p>
              </p>
</dd>
<dt><span class="term">Depends On</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">lazy_variance</span></code> depends on <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">moment</span><span class="special">&lt;</span><span class="number">2</span><span class="special">&gt;</span></code>
                and <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">mean</span></code> <br> <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">variance</span></code>
                depends on <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">count</span></code> and <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">immediate_mean</span></code>
              </p></dd>
<dt><span class="term">Variants</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">lazy_variance</span></code> (a.k.a. <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">variance</span><span class="special">(</span><span class="identifier">lazy</span><span class="special">))</span></code>
                <br> <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">variance</span></code> (a.k.a. <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">variance</span><span class="special">(</span><span class="identifier">immediate</span><span class="special">)</span></code>)
              </p></dd>
<dt><span class="term">Initialization Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Accumulator Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Extractor Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Accumulator Complexity</span></dt>
<dd><p>
                O(1)
              </p></dd>
<dt><span class="term">Extractor Complexity</span></dt>
<dd><p>
                O(1)
              </p></dd>
</dl>
</div>
<p>
          <span class="bold"><strong>Header</strong></span>
        </p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><code class="computeroutput"><a class="link" href="reference.html#header.boost.accumulators.statistics.variance_hpp" title="Header &lt;boost/accumulators/statistics/variance.hpp&gt;">boost/accumulators/statistics/variance.hpp</a></code><span class="special">&gt;</span>
</pre>
<p>
          <span class="bold"><strong>Example</strong></span>
        </p>
<pre class="programlisting"><span class="comment">// lazy variance</span>
<span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">variance</span><span class="special">(</span><span class="identifier">lazy</span><span class="special">)&gt;</span> <span class="special">&gt;</span> <span class="identifier">acc1</span><span class="special">;</span>

<span class="identifier">acc1</span><span class="special">(</span><span class="number">1</span><span class="special">);</span>
<span class="identifier">acc1</span><span class="special">(</span><span class="number">2</span><span class="special">);</span>
<span class="identifier">acc1</span><span class="special">(</span><span class="number">3</span><span class="special">);</span>
<span class="identifier">acc1</span><span class="special">(</span><span class="number">4</span><span class="special">);</span>
<span class="identifier">acc1</span><span class="special">(</span><span class="number">5</span><span class="special">);</span>

<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span><span class="number">5u</span><span class="special">,</span> <span class="identifier">count</span><span class="special">(</span><span class="identifier">acc1</span><span class="special">));</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span><span class="number">3.</span><span class="special">,</span> <span class="identifier">mean</span><span class="special">(</span><span class="identifier">acc1</span><span class="special">),</span> <span class="number">1e-5</span><span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span><span class="number">11.</span><span class="special">,</span> <span class="identifier">accumulators</span><span class="special">::</span><span class="identifier">moment</span><span class="special">&lt;</span><span class="number">2</span><span class="special">&gt;(</span><span class="identifier">acc1</span><span class="special">),</span> <span class="number">1e-5</span><span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span><span class="number">2.</span><span class="special">,</span> <span class="identifier">variance</span><span class="special">(</span><span class="identifier">acc1</span><span class="special">),</span> <span class="number">1e-5</span><span class="special">);</span>

<span class="comment">// immediate variance</span>
<span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">variance</span><span class="special">&gt;</span> <span class="special">&gt;</span> <span class="identifier">acc2</span><span class="special">;</span>

<span class="identifier">acc2</span><span class="special">(</span><span class="number">1</span><span class="special">);</span>
<span class="identifier">acc2</span><span class="special">(</span><span class="number">2</span><span class="special">);</span>
<span class="identifier">acc2</span><span class="special">(</span><span class="number">3</span><span class="special">);</span>
<span class="identifier">acc2</span><span class="special">(</span><span class="number">4</span><span class="special">);</span>
<span class="identifier">acc2</span><span class="special">(</span><span class="number">5</span><span class="special">);</span>

<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span><span class="number">5u</span><span class="special">,</span> <span class="identifier">count</span><span class="special">(</span><span class="identifier">acc2</span><span class="special">));</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span><span class="number">3.</span><span class="special">,</span> <span class="identifier">mean</span><span class="special">(</span><span class="identifier">acc2</span><span class="special">),</span> <span class="number">1e-5</span><span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span><span class="number">2.</span><span class="special">,</span> <span class="identifier">variance</span><span class="special">(</span><span class="identifier">acc2</span><span class="special">),</span> <span class="number">1e-5</span><span class="special">);</span>
</pre>
<p>
          <span class="bold"><strong>See also</strong></span>
        </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
              <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/lazy_variance_impl.html" title="Struct template lazy_variance_impl">lazy_variance_impl</a></code>
            </li>
<li class="listitem">
              <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/variance_impl.html" title="Struct template variance_impl">variance_impl</a></code>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.count" title="count"><code class="literal">count</code></a>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.mean" title="mean and variants"><code class="literal">mean</code></a>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.moment" title="moment"><code class="literal">moment</code></a>
            </li>
</ul></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="accumulators.user_s_guide.the_statistical_accumulators_library.weighted_covariance"></a><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.weighted_covariance" title="weighted_covariance">weighted_covariance</a>
</h4></div></div></div>
<p>
          An iterative Monte Carlo estimator for the weighted covariance. The feature
          is specified as <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_covariance</span><span class="special">&lt;</span><em class="replaceable"><code>variate-type</code></em><span class="special">,</span> <em class="replaceable"><code>variate-tag</code></em><span class="special">&gt;</span></code> and
          is extracted with the <code class="computeroutput"><span class="identifier">weighted_variate</span><span class="special">()</span></code> extractor. For more implementation details,
          see <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/weighted_covariance_impl.html" title="Struct template weighted_covariance_impl">weighted_covariance_impl</a></code>
        </p>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Result Type</span></dt>
<dd>
<p>
</p>
<pre class="programlisting"><span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">outer_product</span><span class="special">&lt;</span>
    <span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">multiplies</span><span class="special">&lt;</span>
        <em class="replaceable"><code>weight-type</code></em>
      <span class="special">,</span> <span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">fdiv</span><span class="special">&lt;</span><em class="replaceable"><code>sample-type</code></em><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">&gt;::</span><span class="identifier">result_type</span>
    <span class="special">&gt;::</span><span class="identifier">result_type</span>
  <span class="special">,</span> <span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">multiplies</span><span class="special">&lt;</span>
        <em class="replaceable"><code>weight-type</code></em>
      <span class="special">,</span> <span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">fdiv</span><span class="special">&lt;</span><em class="replaceable"><code>variate-type</code></em><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">&gt;::</span><span class="identifier">result_type</span>
    <span class="special">&gt;::</span><span class="identifier">result_type</span>
<span class="special">&gt;</span>
</pre>
<p>
              </p>
</dd>
<dt><span class="term">Depends On</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">count</span></code> <br> <code class="computeroutput"><span class="identifier">sum_of_weights</span></code> <br> <code class="computeroutput"><span class="identifier">weighted_mean</span></code> <br> <code class="computeroutput"><span class="identifier">weighted_mean_of_variates</span><span class="special">&lt;</span><em class="replaceable"><code>variate-type</code></em><span class="special">,</span> <em class="replaceable"><code>variate-tag</code></em><span class="special">&gt;</span></code>
              </p></dd>
<dt><span class="term">Variants</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">abstract_weighted_covariance</span></code>
              </p></dd>
<dt><span class="term">Initialization Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Accumulator Parameters</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">weight</span></code> <br> <code class="computeroutput"><em class="replaceable"><code>variate-tag</code></em></code>
              </p></dd>
<dt><span class="term">Extractor Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Accumulator Complexity</span></dt>
<dd><p>
                O(1)
              </p></dd>
<dt><span class="term">Extractor Complexity</span></dt>
<dd><p>
                O(1)
              </p></dd>
</dl>
</div>
<p>
          <span class="bold"><strong>Header</strong></span>
        </p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><code class="computeroutput"><a class="link" href="reference.html#header.boost.accumulators.statistics.weighted_covariance_hpp" title="Header &lt;boost/accumulators/statistics/weighted_covariance.hpp&gt;">boost/accumulators/statistics/weighted_covariance.hpp</a></code><span class="special">&gt;</span>
</pre>
<p>
          <span class="bold"><strong>Example</strong></span>
        </p>
<pre class="programlisting"><span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_covariance</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">,</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">covariate1</span><span class="special">&gt;</span> <span class="special">&gt;,</span> <span class="keyword">double</span> <span class="special">&gt;</span> <span class="identifier">acc</span><span class="special">;</span>

<span class="identifier">acc</span><span class="special">(</span><span class="number">1.</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">1.1</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="number">2.</span><span class="special">);</span>
<span class="identifier">acc</span><span class="special">(</span><span class="number">1.</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">2.2</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="number">4.</span><span class="special">);</span>
<span class="identifier">acc</span><span class="special">(</span><span class="number">2.</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">3.3</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="number">3.</span><span class="special">);</span>
<span class="identifier">acc</span><span class="special">(</span><span class="number">6.</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">4.4</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="number">1.</span><span class="special">);</span>

<span class="keyword">double</span> <span class="identifier">epsilon</span> <span class="special">=</span> <span class="number">1e-6</span><span class="special">;</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span><span class="identifier">weighted_covariance</span><span class="special">(</span><span class="identifier">acc</span><span class="special">),</span> <span class="special">-</span><span class="number">2.39</span><span class="special">,</span> <span class="identifier">epsilon</span><span class="special">);</span>
</pre>
<p>
          <span class="bold"><strong>See also</strong></span>
        </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
              <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/weighted_covariance_impl.html" title="Struct template weighted_covariance_impl">weighted_covariance_impl</a></code>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.count" title="count"><code class="literal">count</code></a>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.sum" title="sum and variants"><code class="literal">sum</code></a>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.weighted_mean" title="weighted_mean and variants"><code class="literal">weighted_mean</code></a>
            </li>
</ul></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="accumulators.user_s_guide.the_statistical_accumulators_library.weighted_density"></a><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.weighted_density" title="weighted_density">weighted_density</a>
</h4></div></div></div>
<p>
          The <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_density</span></code> feature returns a histogram
          of the weighted sample distribution. For more implementation details, see
          <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/weighted_density_impl.html" title="Struct template weighted_density_impl">weighted_density_impl</a></code>.
        </p>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Result Type</span></dt>
<dd>
<p>
</p>
<pre class="programlisting"><span class="identifier">iterator_range</span><span class="special">&lt;</span>
    <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span>
        <span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special">&lt;</span>
            <span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">fdiv</span><span class="special">&lt;</span><em class="replaceable"><code>weight-type</code></em><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">&gt;::</span><span class="identifier">result_type</span>
          <span class="special">,</span> <span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">fdiv</span><span class="special">&lt;</span><em class="replaceable"><code>weight-type</code></em><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">&gt;::</span><span class="identifier">result_type</span>
        <span class="special">&gt;</span>
    <span class="special">&gt;::</span><span class="identifier">iterator</span>
<span class="special">&gt;</span>
</pre>
<p>
              </p>
</dd>
<dt><span class="term">Depends On</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">count</span></code> <br> <code class="computeroutput"><span class="identifier">sum_of_weights</span></code> <br> <code class="computeroutput"><span class="identifier">min</span></code> <br> <code class="computeroutput"><span class="identifier">max</span></code>
              </p></dd>
<dt><span class="term">Variants</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Initialization Parameters</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_density</span><span class="special">::</span><span class="identifier">cache_size</span></code> <br> <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_density</span><span class="special">::</span><span class="identifier">num_bins</span></code>
              </p></dd>
<dt><span class="term">Accumulator Parameters</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">weight</span></code>
              </p></dd>
<dt><span class="term">Extractor Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Accumulator Complexity</span></dt>
<dd><p>
                TODO
              </p></dd>
<dt><span class="term">Extractor Complexity</span></dt>
<dd><p>
                O(N), when N is <code class="computeroutput"><span class="identifier">weighted_density</span><span class="special">::</span><span class="identifier">num_bins</span></code>
              </p></dd>
</dl>
</div>
<p>
          <span class="bold"><strong>Header</strong></span>
        </p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><code class="computeroutput"><a class="link" href="reference.html#header.boost.accumulators.statistics.weighted_density_hpp" title="Header &lt;boost/accumulators/statistics/weighted_density.hpp&gt;">boost/accumulators/statistics/weighted_density.hpp</a></code><span class="special">&gt;</span>
</pre>
<p>
          <span class="bold"><strong>See also</strong></span>
        </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
              <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/weighted_density_impl.html" title="Struct template weighted_density_impl">weighted_density_impl</a></code>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.count" title="count"><code class="literal">count</code></a>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.sum" title="sum and variants"><code class="literal">sum</code></a>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.min" title="min"><code class="literal">min</code></a>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.max" title="max"><code class="literal">max</code></a>
            </li>
</ul></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="accumulators.user_s_guide.the_statistical_accumulators_library.weighted_extended_p_square"></a><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.weighted_extended_p_square" title="weighted_extended_p_square">weighted_extended_p_square</a>
</h4></div></div></div>
<p>
          Multiple quantile estimation with the extended <code class="literal">P^2</code> algorithm
          for weighted samples. For further details, see <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/weigh_1_3_2_6_3_42_1_1_2_1.html" title="Struct template weighted_extended_p_square_impl">weighted_extended_p_square_impl</a></code>.
        </p>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Result Type</span></dt>
<dd>
<p>
</p>
<pre class="programlisting"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">iterator_range</span><span class="special">&lt;</span>
    <em class="replaceable"><code>implementation-defined</code></em>
<span class="special">&gt;</span>
</pre>
<p>
              </p>
</dd>
<dt><span class="term">Depends On</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">count</span></code> <br> <code class="computeroutput"><span class="identifier">sum_of_weights</span></code>
              </p></dd>
<dt><span class="term">Variants</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Initialization Parameters</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_extended_p_square</span><span class="special">::</span><span class="identifier">probabilities</span></code>
              </p></dd>
<dt><span class="term">Accumulator Parameters</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">weight</span></code>
              </p></dd>
<dt><span class="term">Extractor Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Accumulator Complexity</span></dt>
<dd><p>
                TODO
              </p></dd>
<dt><span class="term">Extractor Complexity</span></dt>
<dd><p>
                O(1)
              </p></dd>
</dl>
</div>
<p>
          <span class="bold"><strong>Header</strong></span>
        </p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><code class="computeroutput"><a class="link" href="reference.html#header.boost.accumulators.statistics.weighted_extended_p_square_hpp" title="Header &lt;boost/accumulators/statistics/weighted_extended_p_square.hpp&gt;">boost/accumulators/statistics/weighted_extended_p_square.hpp</a></code><span class="special">&gt;</span>
</pre>
<p>
          <span class="bold"><strong>Example</strong></span>
        </p>
<pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_extended_p_square</span><span class="special">&gt;,</span> <span class="keyword">double</span><span class="special">&gt;</span> <span class="identifier">accumulator_t</span><span class="special">;</span>

<span class="comment">// tolerance in %</span>
<span class="keyword">double</span> <span class="identifier">epsilon</span> <span class="special">=</span> <span class="number">1</span><span class="special">;</span>

<span class="comment">// some random number generators</span>
<span class="keyword">double</span> <span class="identifier">mu1</span> <span class="special">=</span> <span class="special">-</span><span class="number">1.0</span><span class="special">;</span>
<span class="keyword">double</span> <span class="identifier">mu2</span> <span class="special">=</span>  <span class="number">1.0</span><span class="special">;</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">lagged_fibonacci607</span> <span class="identifier">rng</span><span class="special">;</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">normal_distribution</span><span class="special">&lt;&gt;</span> <span class="identifier">mean_sigma1</span><span class="special">(</span><span class="identifier">mu1</span><span class="special">,</span> <span class="number">1</span><span class="special">);</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">normal_distribution</span><span class="special">&lt;&gt;</span> <span class="identifier">mean_sigma2</span><span class="special">(</span><span class="identifier">mu2</span><span class="special">,</span> <span class="number">1</span><span class="special">);</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">variate_generator</span><span class="special">&lt;</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">lagged_fibonacci607</span><span class="special">&amp;,</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">normal_distribution</span><span class="special">&lt;&gt;</span> <span class="special">&gt;</span> <span class="identifier">normal1</span><span class="special">(</span><span class="identifier">rng</span><span class="special">,</span> <span class="identifier">mean_sigma1</span><span class="special">);</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">variate_generator</span><span class="special">&lt;</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">lagged_fibonacci607</span><span class="special">&amp;,</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">normal_distribution</span><span class="special">&lt;&gt;</span> <span class="special">&gt;</span> <span class="identifier">normal2</span><span class="special">(</span><span class="identifier">rng</span><span class="special">,</span> <span class="identifier">mean_sigma2</span><span class="special">);</span>

<span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;</span> <span class="identifier">probs_uniform</span><span class="special">,</span> <span class="identifier">probs_normal1</span><span class="special">,</span> <span class="identifier">probs_normal2</span><span class="special">,</span> <span class="identifier">probs_normal_exact1</span><span class="special">,</span> <span class="identifier">probs_normal_exact2</span><span class="special">;</span>

<span class="keyword">double</span> <span class="identifier">p1</span><span class="special">[]</span> <span class="special">=</span> <span class="special">{/*</span><span class="number">0.001</span><span class="special">,*/</span> <span class="number">0.01</span><span class="special">,</span> <span class="number">0.1</span><span class="special">,</span> <span class="number">0.5</span><span class="special">,</span> <span class="number">0.9</span><span class="special">,</span> <span class="number">0.99</span><span class="special">,</span> <span class="number">0.999</span><span class="special">};</span>
<span class="identifier">probs_uniform</span><span class="special">.</span><span class="identifier">assign</span><span class="special">(</span><span class="identifier">p1</span><span class="special">,</span> <span class="identifier">p1</span> <span class="special">+</span> <span class="keyword">sizeof</span><span class="special">(</span><span class="identifier">p1</span><span class="special">)</span> <span class="special">/</span> <span class="keyword">sizeof</span><span class="special">(</span><span class="keyword">double</span><span class="special">));</span>

<span class="keyword">double</span> <span class="identifier">p2</span><span class="special">[]</span> <span class="special">=</span> <span class="special">{</span><span class="number">0.001</span><span class="special">,</span> <span class="number">0.025</span><span class="special">};</span>
<span class="keyword">double</span> <span class="identifier">p3</span><span class="special">[]</span> <span class="special">=</span> <span class="special">{</span><span class="number">0.975</span><span class="special">,</span> <span class="number">0.999</span><span class="special">};</span>
<span class="identifier">probs_normal1</span><span class="special">.</span><span class="identifier">assign</span><span class="special">(</span><span class="identifier">p2</span><span class="special">,</span> <span class="identifier">p2</span> <span class="special">+</span> <span class="keyword">sizeof</span><span class="special">(</span><span class="identifier">p2</span><span class="special">)</span> <span class="special">/</span> <span class="keyword">sizeof</span><span class="special">(</span><span class="keyword">double</span><span class="special">));</span>
<span class="identifier">probs_normal2</span><span class="special">.</span><span class="identifier">assign</span><span class="special">(</span><span class="identifier">p3</span><span class="special">,</span> <span class="identifier">p3</span> <span class="special">+</span> <span class="keyword">sizeof</span><span class="special">(</span><span class="identifier">p3</span><span class="special">)</span> <span class="special">/</span> <span class="keyword">sizeof</span><span class="special">(</span><span class="keyword">double</span><span class="special">));</span>

<span class="keyword">double</span> <span class="identifier">p4</span><span class="special">[]</span> <span class="special">=</span> <span class="special">{-</span><span class="number">3.090232</span><span class="special">,</span> <span class="special">-</span><span class="number">1.959963</span><span class="special">};</span>
<span class="keyword">double</span> <span class="identifier">p5</span><span class="special">[]</span> <span class="special">=</span> <span class="special">{</span><span class="number">1.959963</span><span class="special">,</span> <span class="number">3.090232</span><span class="special">};</span>
<span class="identifier">probs_normal_exact1</span><span class="special">.</span><span class="identifier">assign</span><span class="special">(</span><span class="identifier">p4</span><span class="special">,</span> <span class="identifier">p4</span> <span class="special">+</span> <span class="keyword">sizeof</span><span class="special">(</span><span class="identifier">p4</span><span class="special">)</span> <span class="special">/</span> <span class="keyword">sizeof</span><span class="special">(</span><span class="keyword">double</span><span class="special">));</span>
<span class="identifier">probs_normal_exact2</span><span class="special">.</span><span class="identifier">assign</span><span class="special">(</span><span class="identifier">p5</span><span class="special">,</span> <span class="identifier">p5</span> <span class="special">+</span> <span class="keyword">sizeof</span><span class="special">(</span><span class="identifier">p5</span><span class="special">)</span> <span class="special">/</span> <span class="keyword">sizeof</span><span class="special">(</span><span class="keyword">double</span><span class="special">));</span>

<span class="identifier">accumulator_t</span> <span class="identifier">acc_uniform</span><span class="special">(</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_extended_p_square</span><span class="special">::</span><span class="identifier">probabilities</span> <span class="special">=</span> <span class="identifier">probs_uniform</span><span class="special">);</span>
<span class="identifier">accumulator_t</span> <span class="identifier">acc_normal1</span><span class="special">(</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_extended_p_square</span><span class="special">::</span><span class="identifier">probabilities</span> <span class="special">=</span> <span class="identifier">probs_normal1</span><span class="special">);</span>
<span class="identifier">accumulator_t</span> <span class="identifier">acc_normal2</span><span class="special">(</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_extended_p_square</span><span class="special">::</span><span class="identifier">probabilities</span> <span class="special">=</span> <span class="identifier">probs_normal2</span><span class="special">);</span>

<span class="keyword">for</span> <span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special">&lt;</span> <span class="number">100000</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
<span class="special">{</span>
    <span class="identifier">acc_uniform</span><span class="special">(</span><span class="identifier">rng</span><span class="special">(),</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">1.</span><span class="special">);</span>

    <span class="keyword">double</span> <span class="identifier">sample1</span> <span class="special">=</span> <span class="identifier">normal1</span><span class="special">();</span>
    <span class="keyword">double</span> <span class="identifier">sample2</span> <span class="special">=</span> <span class="identifier">normal2</span><span class="special">();</span>
    <span class="identifier">acc_normal1</span><span class="special">(</span><span class="identifier">sample1</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">exp</span><span class="special">(-</span><span class="identifier">mu1</span> <span class="special">*</span> <span class="special">(</span><span class="identifier">sample1</span> <span class="special">-</span> <span class="number">0.5</span> <span class="special">*</span> <span class="identifier">mu1</span><span class="special">)));</span>
    <span class="identifier">acc_normal2</span><span class="special">(</span><span class="identifier">sample2</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">exp</span><span class="special">(-</span><span class="identifier">mu2</span> <span class="special">*</span> <span class="special">(</span><span class="identifier">sample2</span> <span class="special">-</span> <span class="number">0.5</span> <span class="special">*</span> <span class="identifier">mu2</span><span class="special">)));</span>
<span class="special">}</span>

<span class="comment">// check for uniform distribution    </span>
<span class="keyword">for</span> <span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special">&lt;</span> <span class="identifier">probs_uniform</span><span class="special">.</span><span class="identifier">size</span><span class="special">();</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
<span class="special">{</span>
    <span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span><span class="identifier">weighted_extended_p_square</span><span class="special">(</span><span class="identifier">acc_uniform</span><span class="special">)[</span><span class="identifier">i</span><span class="special">],</span> <span class="identifier">probs_uniform</span><span class="special">[</span><span class="identifier">i</span><span class="special">],</span> <span class="identifier">epsilon</span><span class="special">);</span>
<span class="special">}</span>

<span class="comment">// check for standard normal distribution</span>
<span class="keyword">for</span> <span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special">&lt;</span> <span class="identifier">probs_normal1</span><span class="special">.</span><span class="identifier">size</span><span class="special">();</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
<span class="special">{</span>
    <span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span><span class="identifier">weighted_extended_p_square</span><span class="special">(</span><span class="identifier">acc_normal1</span><span class="special">)[</span><span class="identifier">i</span><span class="special">],</span> <span class="identifier">probs_normal_exact1</span><span class="special">[</span><span class="identifier">i</span><span class="special">],</span> <span class="identifier">epsilon</span><span class="special">);</span>
    <span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span><span class="identifier">weighted_extended_p_square</span><span class="special">(</span><span class="identifier">acc_normal2</span><span class="special">)[</span><span class="identifier">i</span><span class="special">],</span> <span class="identifier">probs_normal_exact2</span><span class="special">[</span><span class="identifier">i</span><span class="special">],</span> <span class="identifier">epsilon</span><span class="special">);</span>
<span class="special">}</span>
</pre>
<p>
          <span class="bold"><strong>See also</strong></span>
        </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
              <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/weigh_1_3_2_6_3_42_1_1_2_1.html" title="Struct template weighted_extended_p_square_impl">weighted_extended_p_square_impl</a></code>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.count" title="count"><code class="literal">count</code></a>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.sum" title="sum and variants"><code class="literal">sum</code></a>
            </li>
</ul></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="accumulators.user_s_guide.the_statistical_accumulators_library.weighted_kurtosis"></a><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.weighted_kurtosis" title="weighted_kurtosis">weighted_kurtosis</a>
</h4></div></div></div>
<p>
          The kurtosis of a sample distribution is defined as the ratio of the 4th
          central moment and the square of the 2nd central moment (the variance)
          of the samples, minus 3. The term <code class="literal">-3</code> is added in order
          to ensure that the normal distribution has zero kurtosis. For more implementation
          details, see <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/weighted_kurtosis_impl.html" title="Struct template weighted_kurtosis_impl">weighted_kurtosis_impl</a></code>
        </p>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Result Type</span></dt>
<dd>
<p>
</p>
<pre class="programlisting"><span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">fdiv</span><span class="special">&lt;</span>
    <span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">multiplies</span><span class="special">&lt;</span><em class="replaceable"><code>sample-type</code></em><span class="special">,</span> <em class="replaceable"><code>weight-type</code></em><span class="special">&gt;::</span><span class="identifier">result_type</span>
  <span class="special">,</span> <span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">multiplies</span><span class="special">&lt;</span><em class="replaceable"><code>sample-type</code></em><span class="special">,</span> <em class="replaceable"><code>weight-type</code></em><span class="special">&gt;::</span><span class="identifier">result_type</span>
<span class="special">&gt;::</span><span class="identifier">result_type</span>
</pre>
<p>
              </p>
</dd>
<dt><span class="term">Depends On</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">weighted_mean</span></code> <br>
                <code class="computeroutput"><span class="identifier">weighted_moment</span><span class="special">&lt;</span><span class="number">2</span><span class="special">&gt;</span></code>
                <br> <code class="computeroutput"><span class="identifier">weighted_moment</span><span class="special">&lt;</span><span class="number">3</span><span class="special">&gt;</span></code> <br> <code class="computeroutput"><span class="identifier">weighted_moment</span><span class="special">&lt;</span><span class="number">4</span><span class="special">&gt;</span></code>
              </p></dd>
<dt><span class="term">Variants</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Initialization Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Accumulator Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Extractor Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Accumulator Complexity</span></dt>
<dd><p>
                O(1)
              </p></dd>
<dt><span class="term">Extractor Complexity</span></dt>
<dd><p>
                O(1)
              </p></dd>
</dl>
</div>
<p>
          <span class="bold"><strong>Header</strong></span>
        </p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><code class="computeroutput"><a class="link" href="reference.html#header.boost.accumulators.statistics.weighted_kurtosis_hpp" title="Header &lt;boost/accumulators/statistics/weighted_kurtosis.hpp&gt;">boost/accumulators/statistics/weighted_kurtosis.hpp</a></code><span class="special">&gt;</span>
</pre>
<p>
          <span class="bold"><strong>Example</strong></span>
        </p>
<pre class="programlisting"><span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_kurtosis</span><span class="special">&gt;,</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="identifier">acc2</span><span class="special">;</span>

<span class="identifier">acc2</span><span class="special">(</span><span class="number">2</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">4</span><span class="special">);</span>
<span class="identifier">acc2</span><span class="special">(</span><span class="number">7</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">1</span><span class="special">);</span>
<span class="identifier">acc2</span><span class="special">(</span><span class="number">4</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">3</span><span class="special">);</span>
<span class="identifier">acc2</span><span class="special">(</span><span class="number">9</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">1</span><span class="special">);</span>
<span class="identifier">acc2</span><span class="special">(</span><span class="number">3</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">2</span><span class="special">);</span>

<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="identifier">weighted_mean</span><span class="special">(</span><span class="identifier">acc2</span><span class="special">),</span> <span class="number">42.</span><span class="special">/</span><span class="number">11.</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="identifier">accumulators</span><span class="special">::</span><span class="identifier">weighted_moment</span><span class="special">&lt;</span><span class="number">2</span><span class="special">&gt;(</span><span class="identifier">acc2</span><span class="special">),</span> <span class="number">212.</span><span class="special">/</span><span class="number">11.</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="identifier">accumulators</span><span class="special">::</span><span class="identifier">weighted_moment</span><span class="special">&lt;</span><span class="number">3</span><span class="special">&gt;(</span><span class="identifier">acc2</span><span class="special">),</span> <span class="number">1350.</span><span class="special">/</span><span class="number">11.</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="identifier">accumulators</span><span class="special">::</span><span class="identifier">weighted_moment</span><span class="special">&lt;</span><span class="number">4</span><span class="special">&gt;(</span><span class="identifier">acc2</span><span class="special">),</span> <span class="number">9956.</span><span class="special">/</span><span class="number">11.</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">weighted_kurtosis</span><span class="special">(</span><span class="identifier">acc2</span><span class="special">),</span> <span class="number">0.58137026432</span><span class="special">,</span> <span class="number">1e-6</span> <span class="special">);</span>
</pre>
<p>
          <span class="bold"><strong>See also</strong></span>
        </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
              <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/weighted_kurtosis_impl.html" title="Struct template weighted_kurtosis_impl">weighted_kurtosis_impl</a></code>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.weighted_mean" title="weighted_mean and variants"><code class="literal">weighted_mean</code></a>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.weighted_moment" title="weighted_moment"><code class="literal">weighted_moment</code></a>
            </li>
</ul></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="accumulators.user_s_guide.the_statistical_accumulators_library.weighted_mean"></a><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.weighted_mean" title="weighted_mean and variants">weighted_mean
        <span class="emphasis"><em>and variants</em></span></a>
</h4></div></div></div>
<p>
          Calculates the weighted mean of samples or variates. The calculation is
          either lazy (in the result extractor), or immediate (in the accumulator).
          The lazy implementation is the default. For more implementation details,
          see <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/weighted_mean_impl.html" title="Struct template weighted_mean_impl">weighted_mean_impl</a></code>
          or. <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/immed_1_3_2_6_3_44_1_1_6_1.html" title="Struct template immediate_weighted_mean_impl">immediate_weighted_mean_impl</a></code>
        </p>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Result Type</span></dt>
<dd><p>
                For samples, <code class="computeroutput"><span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">fdiv</span><span class="special">&lt;</span><span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">multiplies</span><span class="special">&lt;</span><em class="replaceable"><code>sample-type</code></em><span class="special">,</span> <em class="replaceable"><code>weight-type</code></em><span class="special">&gt;::</span><span class="identifier">result_type</span><span class="special">,</span> <em class="replaceable"><code>weight-type</code></em><span class="special">&gt;::</span><span class="identifier">result_type</span></code> <br> For variates,
                <code class="computeroutput"><span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">fdiv</span><span class="special">&lt;</span><span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">multiplies</span><span class="special">&lt;</span><em class="replaceable"><code>variate-type</code></em><span class="special">,</span> <em class="replaceable"><code>weight-type</code></em><span class="special">&gt;::</span><span class="identifier">result_type</span><span class="special">,</span>
                <em class="replaceable"><code>weight-type</code></em><span class="special">&gt;::</span><span class="identifier">result_type</span></code>
              </p></dd>
<dt><span class="term">Depends On</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">sum_of_weights</span></code> <br>
                The lazy mean of samples depends on <code class="computeroutput"><span class="identifier">weighted_sum</span></code>
                <br> The lazy mean of variates depends on <code class="computeroutput"><span class="identifier">weighted_sum_of_variates</span><span class="special">&lt;&gt;</span></code>
              </p></dd>
<dt><span class="term">Variants</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">weighted_mean_of_variates</span><span class="special">&lt;</span><em class="replaceable"><code>variate-type</code></em><span class="special">,</span> <em class="replaceable"><code>variate-tag</code></em><span class="special">&gt;</span></code> <br> <code class="computeroutput"><span class="identifier">immediate_weighted_mean</span></code>
                <br> <code class="computeroutput"><span class="identifier">immediate_weighted_mean_of_variates</span><span class="special">&lt;</span><em class="replaceable"><code>variate-type</code></em><span class="special">,</span> <em class="replaceable"><code>variate-tag</code></em><span class="special">&gt;</span></code>
              </p></dd>
<dt><span class="term">Initialization Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Accumulator Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Extractor Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Accumulator Complexity</span></dt>
<dd><p>
                O(1)
              </p></dd>
<dt><span class="term">Extractor Complexity</span></dt>
<dd><p>
                O(1)
              </p></dd>
</dl>
</div>
<p>
          <span class="bold"><strong>Header</strong></span>
        </p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><code class="computeroutput"><a class="link" href="reference.html#header.boost.accumulators.statistics.weighted_mean_hpp" title="Header &lt;boost/accumulators/statistics/weighted_mean.hpp&gt;">boost/accumulators/statistics/weighted_mean.hpp</a></code><span class="special">&gt;</span>
</pre>
<p>
          <span class="bold"><strong>Example</strong></span>
        </p>
<pre class="programlisting"><span class="identifier">accumulator_set</span><span class="special">&lt;</span>
    <span class="keyword">int</span>
  <span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span>
        <span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_mean</span>
      <span class="special">,</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_mean_of_variates</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">,</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">covariate1</span><span class="special">&gt;</span>
    <span class="special">&gt;</span>
  <span class="special">,</span> <span class="keyword">int</span>
<span class="special">&gt;</span> <span class="identifier">acc</span><span class="special">;</span>

<span class="identifier">acc</span><span class="special">(</span><span class="number">10</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">2</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="number">7</span><span class="special">);</span>          <span class="comment">//  20</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span><span class="number">2</span><span class="special">,</span> <span class="identifier">sum_of_weights</span><span class="special">(</span><span class="identifier">acc</span><span class="special">));</span>    <span class="comment">//</span>
                                              <span class="comment">//</span>
<span class="identifier">acc</span><span class="special">(</span><span class="number">6</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">3</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="number">8</span><span class="special">);</span>           <span class="comment">//  18</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span><span class="number">5</span><span class="special">,</span> <span class="identifier">sum_of_weights</span><span class="special">(</span><span class="identifier">acc</span><span class="special">));</span>    <span class="comment">//</span>
                                              <span class="comment">//</span>
<span class="identifier">acc</span><span class="special">(</span><span class="number">4</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">4</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="number">9</span><span class="special">);</span>           <span class="comment">//  16</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span><span class="number">9</span><span class="special">,</span> <span class="identifier">sum_of_weights</span><span class="special">(</span><span class="identifier">acc</span><span class="special">));</span>    <span class="comment">//</span>
                                              <span class="comment">//</span>
<span class="identifier">acc</span><span class="special">(</span><span class="number">6</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">5</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="number">6</span><span class="special">);</span>           <span class="comment">//+ 30</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span><span class="number">14</span><span class="special">,</span> <span class="identifier">sum_of_weights</span><span class="special">(</span><span class="identifier">acc</span><span class="special">));</span>   <span class="comment">//</span>
                                              <span class="comment">//= 84  / 14 = 6</span>

<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span><span class="number">6.</span><span class="special">,</span> <span class="identifier">weighted_mean</span><span class="special">(</span><span class="identifier">acc</span><span class="special">));</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span><span class="number">52.</span><span class="special">/</span><span class="number">7.</span><span class="special">,</span> <span class="special">(</span><span class="identifier">accumulators</span><span class="special">::</span><span class="identifier">weighted_mean_of_variates</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">,</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">covariate1</span><span class="special">&gt;(</span><span class="identifier">acc</span><span class="special">)));</span>

<span class="identifier">accumulator_set</span><span class="special">&lt;</span>
    <span class="keyword">int</span>
  <span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span>
        <span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_mean</span><span class="special">(</span><span class="identifier">immediate</span><span class="special">)</span>
      <span class="special">,</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_mean_of_variates</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">,</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">covariate1</span><span class="special">&gt;(</span><span class="identifier">immediate</span><span class="special">)</span>
    <span class="special">&gt;</span>
  <span class="special">,</span> <span class="keyword">int</span>
<span class="special">&gt;</span> <span class="identifier">acc2</span><span class="special">;</span>

<span class="identifier">acc2</span><span class="special">(</span><span class="number">10</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">2</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="number">7</span><span class="special">);</span>         <span class="comment">//  20</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span><span class="number">2</span><span class="special">,</span> <span class="identifier">sum_of_weights</span><span class="special">(</span><span class="identifier">acc2</span><span class="special">));</span>   <span class="comment">//</span>
                                              <span class="comment">//</span>
<span class="identifier">acc2</span><span class="special">(</span><span class="number">6</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">3</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="number">8</span><span class="special">);</span>          <span class="comment">//  18</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span><span class="number">5</span><span class="special">,</span> <span class="identifier">sum_of_weights</span><span class="special">(</span><span class="identifier">acc2</span><span class="special">));</span>   <span class="comment">//</span>
                                              <span class="comment">//</span>
<span class="identifier">acc2</span><span class="special">(</span><span class="number">4</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">4</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="number">9</span><span class="special">);</span>          <span class="comment">//  16</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span><span class="number">9</span><span class="special">,</span> <span class="identifier">sum_of_weights</span><span class="special">(</span><span class="identifier">acc2</span><span class="special">));</span>   <span class="comment">//</span>
                                              <span class="comment">//</span>
<span class="identifier">acc2</span><span class="special">(</span><span class="number">6</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">5</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="number">6</span><span class="special">);</span>          <span class="comment">//+ 30</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span><span class="number">14</span><span class="special">,</span> <span class="identifier">sum_of_weights</span><span class="special">(</span><span class="identifier">acc2</span><span class="special">));</span>  <span class="comment">//</span>
                                              <span class="comment">//= 84  / 14 = 6</span>

<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span><span class="number">6.</span><span class="special">,</span> <span class="identifier">weighted_mean</span><span class="special">(</span><span class="identifier">acc2</span><span class="special">));</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span><span class="number">52.</span><span class="special">/</span><span class="number">7.</span><span class="special">,</span> <span class="special">(</span><span class="identifier">accumulators</span><span class="special">::</span><span class="identifier">weighted_mean_of_variates</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">,</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">covariate1</span><span class="special">&gt;(</span><span class="identifier">acc2</span><span class="special">)));</span>
</pre>
<p>
          <span class="bold"><strong>See also</strong></span>
        </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
              <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/weighted_mean_impl.html" title="Struct template weighted_mean_impl">weighted_mean_impl</a></code>
            </li>
<li class="listitem">
              <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/immed_1_3_2_6_3_44_1_1_6_1.html" title="Struct template immediate_weighted_mean_impl">immediate_weighted_mean_impl</a></code>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.weighted_sum" title="weighted_sum and variants"><code class="literal">weighted_sum</code></a>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.sum" title="sum and variants"><code class="literal">sum</code></a>
            </li>
</ul></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="accumulators.user_s_guide.the_statistical_accumulators_library.weighted_median"></a><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.weighted_median" title="weighted_median and variants">weighted_median
        <span class="emphasis"><em>and variants</em></span></a>
</h4></div></div></div>
<p>
          Median estimation for weighted samples based on the <code class="literal">P^2</code>
          quantile estimator, the density estimator, or the <code class="literal">P^2</code>
          cumulative distribution estimator. For more implementation details, see
          <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/weighted_median_impl.html" title="Struct template weighted_median_impl">weighted_median_impl</a></code>,
          <code class="computeroutput">with_weighted_density_median_impl</code>,
          and <code class="computeroutput">with_weighted_p_square_cumulative_distribution_median_impl</code>.
        </p>
<p>
          The three median accumulators all satisfy the <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_median</span></code>
          feature, and can all be extracted with the <code class="computeroutput"><span class="identifier">weighted_median</span><span class="special">()</span></code> extractor.
        </p>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Result Type</span></dt>
<dd>
<p>
</p>
<pre class="programlisting"><span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">fdiv</span><span class="special">&lt;</span><em class="replaceable"><code>sample-type</code></em><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">&gt;::</span><span class="identifier">result_type</span>
</pre>
<p>
              </p>
</dd>
<dt><span class="term">Depends On</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">weighted_median</span></code> depends
                on <code class="computeroutput"><span class="identifier">weighted_p_square_quantile_for_median</span></code>
                <br> <code class="computeroutput"><span class="identifier">with_weighted_density_median</span></code>
                depends on <code class="computeroutput"><span class="identifier">count</span></code>
                and <code class="computeroutput"><span class="identifier">weighted_density</span></code>
                <br> <code class="computeroutput"><span class="identifier">with_weighted_p_square_cumulative_distribution_median</span></code>
                depends on <code class="computeroutput"><span class="identifier">weighted_p_square_cumulative_distribution</span></code>
              </p></dd>
<dt><span class="term">Variants</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">with_weighted_density_median</span></code>
                (a.k.a. <code class="computeroutput"><span class="identifier">weighted_median</span><span class="special">(</span><span class="identifier">with_weighted_density</span><span class="special">)</span></code>) <br> <code class="computeroutput"><span class="identifier">with_weighted_p_square_cumulative_distribution_median</span></code>
                (a.k.a. <code class="computeroutput"><span class="identifier">weighted_median</span><span class="special">(</span><span class="identifier">with_weighted_p_square_cumulative_distribution</span><span class="special">)</span></code>)
              </p></dd>
<dt><span class="term">Initialization Parameters</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">with_weighted_density_median</span></code>
                requires <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_density</span><span class="special">::</span><span class="identifier">cache_size</span></code> and <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_density</span><span class="special">::</span><span class="identifier">num_bins</span></code>
                <br> <code class="computeroutput"><span class="identifier">with_weighted_p_square_cumulative_distribution_median</span></code>
                requires <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_p_square_cumulative_distribution</span><span class="special">::</span><span class="identifier">num_cells</span></code>
              </p></dd>
<dt><span class="term">Accumulator Parameters</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">weight</span></code>
              </p></dd>
<dt><span class="term">Extractor Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Accumulator Complexity</span></dt>
<dd><p>
                TODO
              </p></dd>
<dt><span class="term">Extractor Complexity</span></dt>
<dd><p>
                TODO
              </p></dd>
</dl>
</div>
<p>
          <span class="bold"><strong>Header</strong></span>
        </p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><code class="computeroutput"><a class="link" href="reference.html#header.boost.accumulators.statistics.weighted_median_hpp" title="Header &lt;boost/accumulators/statistics/weighted_median.hpp&gt;">boost/accumulators/statistics/weighted_median.hpp</a></code><span class="special">&gt;</span>
</pre>
<p>
          <span class="bold"><strong>Example</strong></span>
        </p>
<pre class="programlisting"><span class="comment">// Median estimation of normal distribution N(1,1) using samples from a narrow normal distribution N(1,0.01)</span>
<span class="comment">// The weights equal to the likelihood ratio of the corresponding samples</span>

<span class="comment">// two random number generators</span>
<span class="keyword">double</span> <span class="identifier">mu</span> <span class="special">=</span> <span class="number">1.</span><span class="special">;</span>
<span class="keyword">double</span> <span class="identifier">sigma_narrow</span> <span class="special">=</span> <span class="number">0.01</span><span class="special">;</span>
<span class="keyword">double</span> <span class="identifier">sigma</span> <span class="special">=</span> <span class="number">1.</span><span class="special">;</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">lagged_fibonacci607</span> <span class="identifier">rng</span><span class="special">;</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">normal_distribution</span><span class="special">&lt;&gt;</span> <span class="identifier">mean_sigma_narrow</span><span class="special">(</span><span class="identifier">mu</span><span class="special">,</span><span class="identifier">sigma_narrow</span><span class="special">);</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">variate_generator</span><span class="special">&lt;</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">lagged_fibonacci607</span><span class="special">&amp;,</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">normal_distribution</span><span class="special">&lt;&gt;</span> <span class="special">&gt;</span> <span class="identifier">normal_narrow</span><span class="special">(</span><span class="identifier">rng</span><span class="special">,</span> <span class="identifier">mean_sigma_narrow</span><span class="special">);</span>

<span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_median</span><span class="special">(</span><span class="identifier">with_weighted_p_square_quantile</span><span class="special">)</span> <span class="special">&gt;,</span> <span class="keyword">double</span> <span class="special">&gt;</span> <span class="identifier">acc</span><span class="special">;</span>
<span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_median</span><span class="special">(</span><span class="identifier">with_weighted_density</span><span class="special">)</span> <span class="special">&gt;,</span> <span class="keyword">double</span> <span class="special">&gt;</span>
    <span class="identifier">acc_dens</span><span class="special">(</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_density</span><span class="special">::</span><span class="identifier">cache_size</span> <span class="special">=</span> <span class="number">10000</span><span class="special">,</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_density</span><span class="special">::</span><span class="identifier">num_bins</span> <span class="special">=</span> <span class="number">1000</span> <span class="special">);</span>
<span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_median</span><span class="special">(</span><span class="identifier">with_weighted_p_square_cumulative_distribution</span><span class="special">)</span> <span class="special">&gt;,</span> <span class="keyword">double</span> <span class="special">&gt;</span>
    <span class="identifier">acc_cdist</span><span class="special">(</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_p_square_cumulative_distribution</span><span class="special">::</span><span class="identifier">num_cells</span> <span class="special">=</span> <span class="number">100</span> <span class="special">);</span>

<span class="keyword">for</span> <span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">i</span><span class="special">=</span><span class="number">0</span><span class="special">;</span> <span class="identifier">i</span><span class="special">&lt;</span><span class="number">100000</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
<span class="special">{</span>
    <span class="keyword">double</span> <span class="identifier">sample</span> <span class="special">=</span> <span class="identifier">normal_narrow</span><span class="special">();</span>
    <span class="identifier">acc</span><span class="special">(</span><span class="identifier">sample</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">exp</span><span class="special">(</span><span class="number">0.5</span> <span class="special">*</span> <span class="special">(</span><span class="identifier">sample</span> <span class="special">-</span> <span class="identifier">mu</span><span class="special">)</span> <span class="special">*</span> <span class="special">(</span><span class="identifier">sample</span> <span class="special">-</span> <span class="identifier">mu</span><span class="special">)</span> <span class="special">*</span> <span class="special">(</span> <span class="number">1.</span><span class="special">/</span><span class="identifier">sigma_narrow</span><span class="special">/</span><span class="identifier">sigma_narrow</span> <span class="special">-</span> <span class="number">1.</span><span class="special">/</span><span class="identifier">sigma</span><span class="special">/</span><span class="identifier">sigma</span> <span class="special">)));</span>
    <span class="identifier">acc_dens</span><span class="special">(</span><span class="identifier">sample</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">exp</span><span class="special">(</span><span class="number">0.5</span> <span class="special">*</span> <span class="special">(</span><span class="identifier">sample</span> <span class="special">-</span> <span class="identifier">mu</span><span class="special">)</span> <span class="special">*</span> <span class="special">(</span><span class="identifier">sample</span> <span class="special">-</span> <span class="identifier">mu</span><span class="special">)</span> <span class="special">*</span> <span class="special">(</span> <span class="number">1.</span><span class="special">/</span><span class="identifier">sigma_narrow</span><span class="special">/</span><span class="identifier">sigma_narrow</span> <span class="special">-</span> <span class="number">1.</span><span class="special">/</span><span class="identifier">sigma</span><span class="special">/</span><span class="identifier">sigma</span> <span class="special">)));</span>
    <span class="identifier">acc_cdist</span><span class="special">(</span><span class="identifier">sample</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">exp</span><span class="special">(</span><span class="number">0.5</span> <span class="special">*</span> <span class="special">(</span><span class="identifier">sample</span> <span class="special">-</span> <span class="identifier">mu</span><span class="special">)</span> <span class="special">*</span> <span class="special">(</span><span class="identifier">sample</span> <span class="special">-</span> <span class="identifier">mu</span><span class="special">)</span> <span class="special">*</span> <span class="special">(</span> <span class="number">1.</span><span class="special">/</span><span class="identifier">sigma_narrow</span><span class="special">/</span><span class="identifier">sigma_narrow</span> <span class="special">-</span> <span class="number">1.</span><span class="special">/</span><span class="identifier">sigma</span><span class="special">/</span><span class="identifier">sigma</span> <span class="special">)));</span>
<span class="special">}</span>

<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span><span class="number">1.</span><span class="special">,</span> <span class="identifier">weighted_median</span><span class="special">(</span><span class="identifier">acc</span><span class="special">),</span> <span class="number">1e-1</span><span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span><span class="number">1.</span><span class="special">,</span> <span class="identifier">weighted_median</span><span class="special">(</span><span class="identifier">acc_dens</span><span class="special">),</span> <span class="number">1e-1</span><span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span><span class="number">1.</span><span class="special">,</span> <span class="identifier">weighted_median</span><span class="special">(</span><span class="identifier">acc_cdist</span><span class="special">),</span> <span class="number">1e-1</span><span class="special">);</span>
</pre>
<p>
          <span class="bold"><strong>See also</strong></span>
        </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
              <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/weighted_median_impl.html" title="Struct template weighted_median_impl">weighted_median_impl</a></code>
            </li>
<li class="listitem">
              <code class="computeroutput">with_weighted_density_median_impl</code>
            </li>
<li class="listitem">
              <code class="computeroutput">with_weighted_p_square_cumulative_distribution_median_impl</code>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.count" title="count"><code class="literal">count</code></a>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.weighted_p_square_quantile" title="weighted_p_square_quantile and variants"><code class="literal">weighted_p_square_quantile</code></a>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.weighted_p_square_cumulative_distribution" title="weighted_p_square_cumulative_distribution"><code class="literal">weighted_p_square_cumulative_distribution</code></a>
            </li>
</ul></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="accumulators.user_s_guide.the_statistical_accumulators_library.weighted_moment"></a><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.weighted_moment" title="weighted_moment">weighted_moment</a>
</h4></div></div></div>
<p>
          Calculates the N-th moment of the weighted samples, which is defined as
          the sum of the weighted N-th power of the samples over the sum of the weights.
        </p>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Result Type</span></dt>
<dd>
<p>
</p>
<pre class="programlisting"><span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">fdiv</span><span class="special">&lt;</span>
    <span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">multiplies</span><span class="special">&lt;</span><em class="replaceable"><code>sample-type</code></em><span class="special">,</span> <em class="replaceable"><code>weight-type</code></em><span class="special">&gt;::</span><span class="identifier">result_type</span>
  <span class="special">,</span> <span class="identifier">weight_type</span>
<span class="special">&gt;::</span><span class="identifier">result_type</span>
</pre>
<p>
              </p>
</dd>
<dt><span class="term">Depends On</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">count</span></code> <br> <code class="computeroutput"><span class="identifier">sum_of_weights</span></code>
              </p></dd>
<dt><span class="term">Variants</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Initialization Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Accumulator Parameters</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">weight</span></code>
              </p></dd>
<dt><span class="term">Extractor Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Accumulator Complexity</span></dt>
<dd><p>
                O(1)
              </p></dd>
<dt><span class="term">Extractor Complexity</span></dt>
<dd><p>
                O(1)
              </p></dd>
</dl>
</div>
<p>
          <span class="bold"><strong>Header</strong></span>
        </p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><code class="computeroutput"><a class="link" href="reference.html#header.boost.accumulators.statistics.weighted_moment_hpp" title="Header &lt;boost/accumulators/statistics/weighted_moment.hpp&gt;">boost/accumulators/statistics/weighted_moment.hpp</a></code><span class="special">&gt;</span>
</pre>
<p>
          <span class="bold"><strong>Example</strong></span>
        </p>
<pre class="programlisting"><span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_moment</span><span class="special">&lt;</span><span class="number">2</span><span class="special">&gt;</span> <span class="special">&gt;,</span> <span class="keyword">double</span><span class="special">&gt;</span> <span class="identifier">acc2</span><span class="special">;</span>
<span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_moment</span><span class="special">&lt;</span><span class="number">7</span><span class="special">&gt;</span> <span class="special">&gt;,</span> <span class="keyword">double</span><span class="special">&gt;</span> <span class="identifier">acc7</span><span class="special">;</span>

<span class="identifier">acc2</span><span class="special">(</span><span class="number">2.1</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">0.7</span><span class="special">);</span>
<span class="identifier">acc2</span><span class="special">(</span><span class="number">2.7</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">1.4</span><span class="special">);</span>
<span class="identifier">acc2</span><span class="special">(</span><span class="number">1.8</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">0.9</span><span class="special">);</span>

<span class="identifier">acc7</span><span class="special">(</span><span class="number">2.1</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">0.7</span><span class="special">);</span>
<span class="identifier">acc7</span><span class="special">(</span><span class="number">2.7</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">1.4</span><span class="special">);</span>
<span class="identifier">acc7</span><span class="special">(</span><span class="number">1.8</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">0.9</span><span class="special">);</span>

<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span><span class="number">5.403</span><span class="special">,</span> <span class="identifier">accumulators</span><span class="special">::</span><span class="identifier">weighted_moment</span><span class="special">&lt;</span><span class="number">2</span><span class="special">&gt;(</span><span class="identifier">acc2</span><span class="special">),</span> <span class="number">1e-5</span><span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span><span class="number">548.54182</span><span class="special">,</span> <span class="identifier">accumulators</span><span class="special">::</span><span class="identifier">weighted_moment</span><span class="special">&lt;</span><span class="number">7</span><span class="special">&gt;(</span><span class="identifier">acc7</span><span class="special">),</span> <span class="number">1e-5</span><span class="special">);</span>
</pre>
<p>
          <span class="bold"><strong>See also</strong></span>
        </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
              <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/weighted_moment_impl.html" title="Struct template weighted_moment_impl">weighted_moment_impl</a></code>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.count" title="count"><code class="literal">count</code></a>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.sum" title="sum and variants"><code class="literal">sum</code></a>
            </li>
</ul></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="accumulators.user_s_guide.the_statistical_accumulators_library.weighted_p_square_cumulative_distribution"></a><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.weighted_p_square_cumulative_distribution" title="weighted_p_square_cumulative_distribution">weighted_p_square_cumulative_distribution</a>
</h4></div></div></div>
<p>
          Histogram calculation of the cumulative distribution with the <code class="literal">P^2</code>
          algorithm for weighted samples. For more implementation details, see <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/weigh_1_3_2_6_3_47_1_1_2_1.html" title="Struct template weighted_p_square_cumulative_distribution_impl">weighted_p_square_cumulative_distribution_impl</a></code>
        </p>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Result Type</span></dt>
<dd>
<p>
</p>
<pre class="programlisting"><span class="identifier">iterator_range</span><span class="special">&lt;</span>
    <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span>
        <span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special">&lt;</span>
            <span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">fdiv</span><span class="special">&lt;</span><span class="identifier">weighted_sample</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">&gt;::</span><span class="identifier">result_type</span>
          <span class="special">,</span> <span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">fdiv</span><span class="special">&lt;</span><span class="identifier">weighted_sample</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">&gt;::</span><span class="identifier">result_type</span>
        <span class="special">&gt;</span>
    <span class="special">&gt;::</span><span class="identifier">iterator</span>
<span class="special">&gt;</span>
</pre>
<p>
                where <code class="computeroutput"><span class="identifier">weighted_sample</span></code>
                is <code class="computeroutput"><span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">multiplies</span><span class="special">&lt;</span><em class="replaceable"><code>sample-type</code></em><span class="special">,</span> <em class="replaceable"><code>weight-type</code></em><span class="special">&gt;::</span><span class="identifier">result_type</span></code>
              </p>
</dd>
<dt><span class="term">Depends On</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">count</span></code> <br> <code class="computeroutput"><span class="identifier">sum_or_weights</span></code>
              </p></dd>
<dt><span class="term">Variants</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Initialization Parameters</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_p_square_cumulative_distribution</span><span class="special">::</span><span class="identifier">num_cells</span></code>
              </p></dd>
<dt><span class="term">Accumulator Parameters</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">weight</span></code>
              </p></dd>
<dt><span class="term">Extractor Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Accumulator Complexity</span></dt>
<dd><p>
                TODO
              </p></dd>
<dt><span class="term">Extractor Complexity</span></dt>
<dd><p>
                O(N) where N is <code class="computeroutput"><span class="identifier">num_cells</span></code>
              </p></dd>
</dl>
</div>
<p>
          <span class="bold"><strong>Header</strong></span>
        </p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><code class="computeroutput"><a class="link" href="reference.html#header.boost.accumulators.statistics.weighted_p_square_cumul_dist_hpp" title="Header &lt;boost/accumulators/statistics/weighted_p_square_cumul_dist.hpp&gt;">boost/accumulators/statistics/weighted_p_square_cumul_dist.hpp</a></code><span class="special">&gt;</span>
</pre>
<p>
          <span class="bold"><strong>Example</strong></span>
        </p>
<pre class="programlisting"><span class="comment">// tolerance in %</span>
<span class="keyword">double</span> <span class="identifier">epsilon</span> <span class="special">=</span> <span class="number">4</span><span class="special">;</span>

<span class="keyword">typedef</span> <span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_p_square_cumulative_distribution</span><span class="special">&gt;,</span> <span class="keyword">double</span> <span class="special">&gt;</span> <span class="identifier">accumulator_t</span><span class="special">;</span>

<span class="identifier">accumulator_t</span> <span class="identifier">acc_upper</span><span class="special">(</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_p_square_cumulative_distribution</span><span class="special">::</span><span class="identifier">num_cells</span> <span class="special">=</span> <span class="number">100</span><span class="special">);</span>
<span class="identifier">accumulator_t</span> <span class="identifier">acc_lower</span><span class="special">(</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_p_square_cumulative_distribution</span><span class="special">::</span><span class="identifier">num_cells</span> <span class="special">=</span> <span class="number">100</span><span class="special">);</span>

<span class="comment">// two random number generators</span>
<span class="keyword">double</span> <span class="identifier">mu_upper</span> <span class="special">=</span> <span class="number">1.0</span><span class="special">;</span>
<span class="keyword">double</span> <span class="identifier">mu_lower</span> <span class="special">=</span> <span class="special">-</span><span class="number">1.0</span><span class="special">;</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">lagged_fibonacci607</span> <span class="identifier">rng</span><span class="special">;</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">normal_distribution</span><span class="special">&lt;&gt;</span> <span class="identifier">mean_sigma_upper</span><span class="special">(</span><span class="identifier">mu_upper</span><span class="special">,</span><span class="number">1</span><span class="special">);</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">normal_distribution</span><span class="special">&lt;&gt;</span> <span class="identifier">mean_sigma_lower</span><span class="special">(</span><span class="identifier">mu_lower</span><span class="special">,</span><span class="number">1</span><span class="special">);</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">variate_generator</span><span class="special">&lt;</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">lagged_fibonacci607</span><span class="special">&amp;,</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">normal_distribution</span><span class="special">&lt;&gt;</span> <span class="special">&gt;</span> <span class="identifier">normal_upper</span><span class="special">(</span><span class="identifier">rng</span><span class="special">,</span> <span class="identifier">mean_sigma_upper</span><span class="special">);</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">variate_generator</span><span class="special">&lt;</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">lagged_fibonacci607</span><span class="special">&amp;,</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">normal_distribution</span><span class="special">&lt;&gt;</span> <span class="special">&gt;</span> <span class="identifier">normal_lower</span><span class="special">(</span><span class="identifier">rng</span><span class="special">,</span> <span class="identifier">mean_sigma_lower</span><span class="special">);</span>

<span class="keyword">for</span> <span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">i</span><span class="special">=</span><span class="number">0</span><span class="special">;</span> <span class="identifier">i</span><span class="special">&lt;</span><span class="number">100000</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
<span class="special">{</span>
    <span class="keyword">double</span> <span class="identifier">sample</span> <span class="special">=</span> <span class="identifier">normal_upper</span><span class="special">();</span>
    <span class="identifier">acc_upper</span><span class="special">(</span><span class="identifier">sample</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">exp</span><span class="special">(-</span><span class="identifier">mu_upper</span> <span class="special">*</span> <span class="special">(</span><span class="identifier">sample</span> <span class="special">-</span> <span class="number">0.5</span> <span class="special">*</span> <span class="identifier">mu_upper</span><span class="special">)));</span>
<span class="special">}</span>

<span class="keyword">for</span> <span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">i</span><span class="special">=</span><span class="number">0</span><span class="special">;</span> <span class="identifier">i</span><span class="special">&lt;</span><span class="number">100000</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
<span class="special">{</span>
    <span class="keyword">double</span> <span class="identifier">sample</span> <span class="special">=</span> <span class="identifier">normal_lower</span><span class="special">();</span>
    <span class="identifier">acc_lower</span><span class="special">(</span><span class="identifier">sample</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">exp</span><span class="special">(-</span><span class="identifier">mu_lower</span> <span class="special">*</span> <span class="special">(</span><span class="identifier">sample</span> <span class="special">-</span> <span class="number">0.5</span> <span class="special">*</span> <span class="identifier">mu_lower</span><span class="special">)));</span>
<span class="special">}</span>

<span class="keyword">typedef</span> <span class="identifier">iterator_range</span><span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">,</span> <span class="keyword">double</span><span class="special">&gt;</span> <span class="special">&gt;::</span><span class="identifier">iterator</span> <span class="special">&gt;</span> <span class="identifier">histogram_type</span><span class="special">;</span>
<span class="identifier">histogram_type</span> <span class="identifier">histogram_upper</span> <span class="special">=</span> <span class="identifier">weighted_p_square_cumulative_distribution</span><span class="special">(</span><span class="identifier">acc_upper</span><span class="special">);</span>
<span class="identifier">histogram_type</span> <span class="identifier">histogram_lower</span> <span class="special">=</span> <span class="identifier">weighted_p_square_cumulative_distribution</span><span class="special">(</span><span class="identifier">acc_lower</span><span class="special">);</span>

<span class="comment">// Note that applying importance sampling results in a region of the distribution </span>
<span class="comment">// to be estimated more accurately and another region to be estimated less accurately</span>
<span class="comment">// than without importance sampling, i.e., with unweighted samples</span>

<span class="keyword">for</span> <span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special">&lt;</span> <span class="identifier">histogram_upper</span><span class="special">.</span><span class="identifier">size</span><span class="special">();</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
<span class="special">{</span>
    <span class="comment">// problem with small results: epsilon is relative (in percent), not absolute!</span>

    <span class="comment">// check upper region of distribution</span>
    <span class="keyword">if</span> <span class="special">(</span> <span class="identifier">histogram_upper</span><span class="special">[</span><span class="identifier">i</span><span class="special">].</span><span class="identifier">second</span> <span class="special">&gt;</span> <span class="number">0.1</span> <span class="special">)</span>
        <span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="number">0.5</span> <span class="special">*</span> <span class="special">(</span><span class="number">1.0</span> <span class="special">+</span> <span class="identifier">erf</span><span class="special">(</span> <span class="identifier">histogram_upper</span><span class="special">[</span><span class="identifier">i</span><span class="special">].</span><span class="identifier">first</span> <span class="special">/</span> <span class="identifier">sqrt</span><span class="special">(</span><span class="number">2.0</span><span class="special">)</span> <span class="special">)),</span> <span class="identifier">histogram_upper</span><span class="special">[</span><span class="identifier">i</span><span class="special">].</span><span class="identifier">second</span><span class="special">,</span> <span class="identifier">epsilon</span> <span class="special">);</span>
    <span class="comment">// check lower region of distribution</span>
    <span class="keyword">if</span> <span class="special">(</span> <span class="identifier">histogram_lower</span><span class="special">[</span><span class="identifier">i</span><span class="special">].</span><span class="identifier">second</span> <span class="special">&lt;</span> <span class="special">-</span><span class="number">0.1</span> <span class="special">)</span>
        <span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="number">0.5</span> <span class="special">*</span> <span class="special">(</span><span class="number">1.0</span> <span class="special">+</span> <span class="identifier">erf</span><span class="special">(</span> <span class="identifier">histogram_lower</span><span class="special">[</span><span class="identifier">i</span><span class="special">].</span><span class="identifier">first</span> <span class="special">/</span> <span class="identifier">sqrt</span><span class="special">(</span><span class="number">2.0</span><span class="special">)</span> <span class="special">)),</span> <span class="identifier">histogram_lower</span><span class="special">[</span><span class="identifier">i</span><span class="special">].</span><span class="identifier">second</span><span class="special">,</span> <span class="identifier">epsilon</span> <span class="special">);</span>
<span class="special">}</span>
</pre>
<p>
          <span class="bold"><strong>See also</strong></span>
        </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
              <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/weigh_1_3_2_6_3_47_1_1_2_1.html" title="Struct template weighted_p_square_cumulative_distribution_impl">weighted_p_square_cumulative_distribution_impl</a></code>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.count" title="count"><code class="literal">count</code></a>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.sum" title="sum and variants"><code class="literal">sum</code></a>
            </li>
</ul></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="accumulators.user_s_guide.the_statistical_accumulators_library.weighted_p_square_quantile"></a><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.weighted_p_square_quantile" title="weighted_p_square_quantile and variants">weighted_p_square_quantile
        <span class="emphasis"><em>and variants</em></span></a>
</h4></div></div></div>
<p>
          Single quantile estimation with the <code class="literal">P^2</code> algorithm. For
          more implementation details, see <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/weigh_1_3_2_6_3_49_1_1_2_1.html" title="Struct template weighted_p_square_quantile_impl">weighted_p_square_quantile_impl</a></code>
        </p>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Result Type</span></dt>
<dd>
<p>
</p>
<pre class="programlisting"><span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">fdiv</span><span class="special">&lt;</span>
    <span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">multiplies</span><span class="special">&lt;</span><em class="replaceable"><code>sample-type</code></em><span class="special">,</span> <em class="replaceable"><code>weight-type</code></em><span class="special">&gt;::</span><span class="identifier">result_type</span>
  <span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span>
<span class="special">&gt;::</span><span class="identifier">result_type</span>
</pre>
<p>
              </p>
</dd>
<dt><span class="term">Depends On</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">count</span></code> <br> <code class="computeroutput"><span class="identifier">sum_of_weights</span></code>
              </p></dd>
<dt><span class="term">Variants</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">weighted_p_square_quantile_for_median</span></code>
              </p></dd>
<dt><span class="term">Initialization Parameters</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">quantile_probability</span></code>,
                which defaults to <code class="computeroutput"><span class="number">0.5</span></code>.
                (Note: for <code class="computeroutput"><span class="identifier">weighted_p_square_quantile_for_median</span></code>,
                the <code class="computeroutput"><span class="identifier">quantile_probability</span></code>
                parameter is ignored and is always <code class="computeroutput"><span class="number">0.5</span></code>.)
              </p></dd>
<dt><span class="term">Accumulator Parameters</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">weight</span></code>
              </p></dd>
<dt><span class="term">Extractor Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Accumulator Complexity</span></dt>
<dd><p>
                TODO
              </p></dd>
<dt><span class="term">Extractor Complexity</span></dt>
<dd><p>
                O(1)
              </p></dd>
</dl>
</div>
<p>
          <span class="bold"><strong>Header</strong></span>
        </p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><code class="computeroutput"><a class="link" href="reference.html#header.boost.accumulators.statistics.weighted_p_square_quantile_hpp" title="Header &lt;boost/accumulators/statistics/weighted_p_square_quantile.hpp&gt;">boost/accumulators/statistics/weighted_p_square_quantile.hpp</a></code><span class="special">&gt;</span>
</pre>
<p>
          <span class="bold"><strong>Example</strong></span>
        </p>
<pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_p_square_quantile</span><span class="special">&gt;,</span> <span class="keyword">double</span><span class="special">&gt;</span> <span class="identifier">accumulator_t</span><span class="special">;</span>

<span class="comment">// tolerance in %</span>
<span class="keyword">double</span> <span class="identifier">epsilon</span> <span class="special">=</span> <span class="number">1</span><span class="special">;</span>

<span class="comment">// some random number generators</span>
<span class="keyword">double</span> <span class="identifier">mu4</span> <span class="special">=</span> <span class="special">-</span><span class="number">1.0</span><span class="special">;</span>
<span class="keyword">double</span> <span class="identifier">mu5</span> <span class="special">=</span> <span class="special">-</span><span class="number">1.0</span><span class="special">;</span>
<span class="keyword">double</span> <span class="identifier">mu6</span> <span class="special">=</span> <span class="number">1.0</span><span class="special">;</span>
<span class="keyword">double</span> <span class="identifier">mu7</span> <span class="special">=</span> <span class="number">1.0</span><span class="special">;</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">lagged_fibonacci607</span> <span class="identifier">rng</span><span class="special">;</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">normal_distribution</span><span class="special">&lt;&gt;</span> <span class="identifier">mean_sigma4</span><span class="special">(</span><span class="identifier">mu4</span><span class="special">,</span> <span class="number">1</span><span class="special">);</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">normal_distribution</span><span class="special">&lt;&gt;</span> <span class="identifier">mean_sigma5</span><span class="special">(</span><span class="identifier">mu5</span><span class="special">,</span> <span class="number">1</span><span class="special">);</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">normal_distribution</span><span class="special">&lt;&gt;</span> <span class="identifier">mean_sigma6</span><span class="special">(</span><span class="identifier">mu6</span><span class="special">,</span> <span class="number">1</span><span class="special">);</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">normal_distribution</span><span class="special">&lt;&gt;</span> <span class="identifier">mean_sigma7</span><span class="special">(</span><span class="identifier">mu7</span><span class="special">,</span> <span class="number">1</span><span class="special">);</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">variate_generator</span><span class="special">&lt;</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">lagged_fibonacci607</span><span class="special">&amp;,</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">normal_distribution</span><span class="special">&lt;&gt;</span> <span class="special">&gt;</span> <span class="identifier">normal4</span><span class="special">(</span><span class="identifier">rng</span><span class="special">,</span> <span class="identifier">mean_sigma4</span><span class="special">);</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">variate_generator</span><span class="special">&lt;</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">lagged_fibonacci607</span><span class="special">&amp;,</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">normal_distribution</span><span class="special">&lt;&gt;</span> <span class="special">&gt;</span> <span class="identifier">normal5</span><span class="special">(</span><span class="identifier">rng</span><span class="special">,</span> <span class="identifier">mean_sigma5</span><span class="special">);</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">variate_generator</span><span class="special">&lt;</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">lagged_fibonacci607</span><span class="special">&amp;,</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">normal_distribution</span><span class="special">&lt;&gt;</span> <span class="special">&gt;</span> <span class="identifier">normal6</span><span class="special">(</span><span class="identifier">rng</span><span class="special">,</span> <span class="identifier">mean_sigma6</span><span class="special">);</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">variate_generator</span><span class="special">&lt;</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">lagged_fibonacci607</span><span class="special">&amp;,</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">normal_distribution</span><span class="special">&lt;&gt;</span> <span class="special">&gt;</span> <span class="identifier">normal7</span><span class="special">(</span><span class="identifier">rng</span><span class="special">,</span> <span class="identifier">mean_sigma7</span><span class="special">);</span>

<span class="identifier">accumulator_t</span> <span class="identifier">acc0</span><span class="special">(</span><span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.001</span><span class="special">);</span>
<span class="identifier">accumulator_t</span> <span class="identifier">acc1</span><span class="special">(</span><span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.025</span><span class="special">);</span>
<span class="identifier">accumulator_t</span> <span class="identifier">acc2</span><span class="special">(</span><span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.975</span><span class="special">);</span>
<span class="identifier">accumulator_t</span> <span class="identifier">acc3</span><span class="special">(</span><span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.999</span><span class="special">);</span>

<span class="identifier">accumulator_t</span> <span class="identifier">acc4</span><span class="special">(</span><span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.001</span><span class="special">);</span>
<span class="identifier">accumulator_t</span> <span class="identifier">acc5</span><span class="special">(</span><span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.025</span><span class="special">);</span>
<span class="identifier">accumulator_t</span> <span class="identifier">acc6</span><span class="special">(</span><span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.975</span><span class="special">);</span>
<span class="identifier">accumulator_t</span> <span class="identifier">acc7</span><span class="special">(</span><span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.999</span><span class="special">);</span>


<span class="keyword">for</span> <span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">i</span><span class="special">=</span><span class="number">0</span><span class="special">;</span> <span class="identifier">i</span><span class="special">&lt;</span><span class="number">100000</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
<span class="special">{</span>
    <span class="keyword">double</span> <span class="identifier">sample</span> <span class="special">=</span> <span class="identifier">rng</span><span class="special">();</span>
    <span class="identifier">acc0</span><span class="special">(</span><span class="identifier">sample</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">1.</span><span class="special">);</span>
    <span class="identifier">acc1</span><span class="special">(</span><span class="identifier">sample</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">1.</span><span class="special">);</span>
    <span class="identifier">acc2</span><span class="special">(</span><span class="identifier">sample</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">1.</span><span class="special">);</span>
    <span class="identifier">acc3</span><span class="special">(</span><span class="identifier">sample</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">1.</span><span class="special">);</span>

    <span class="keyword">double</span> <span class="identifier">sample4</span> <span class="special">=</span> <span class="identifier">normal4</span><span class="special">();</span>
    <span class="keyword">double</span> <span class="identifier">sample5</span> <span class="special">=</span> <span class="identifier">normal5</span><span class="special">();</span>
    <span class="keyword">double</span> <span class="identifier">sample6</span> <span class="special">=</span> <span class="identifier">normal6</span><span class="special">();</span>
    <span class="keyword">double</span> <span class="identifier">sample7</span> <span class="special">=</span> <span class="identifier">normal7</span><span class="special">();</span>
    <span class="identifier">acc4</span><span class="special">(</span><span class="identifier">sample4</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">exp</span><span class="special">(-</span><span class="identifier">mu4</span> <span class="special">*</span> <span class="special">(</span><span class="identifier">sample4</span> <span class="special">-</span> <span class="number">0.5</span> <span class="special">*</span> <span class="identifier">mu4</span><span class="special">)));</span>
    <span class="identifier">acc5</span><span class="special">(</span><span class="identifier">sample5</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">exp</span><span class="special">(-</span><span class="identifier">mu5</span> <span class="special">*</span> <span class="special">(</span><span class="identifier">sample5</span> <span class="special">-</span> <span class="number">0.5</span> <span class="special">*</span> <span class="identifier">mu5</span><span class="special">)));</span>
    <span class="identifier">acc6</span><span class="special">(</span><span class="identifier">sample6</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">exp</span><span class="special">(-</span><span class="identifier">mu6</span> <span class="special">*</span> <span class="special">(</span><span class="identifier">sample6</span> <span class="special">-</span> <span class="number">0.5</span> <span class="special">*</span> <span class="identifier">mu6</span><span class="special">)));</span>
    <span class="identifier">acc7</span><span class="special">(</span><span class="identifier">sample7</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">exp</span><span class="special">(-</span><span class="identifier">mu7</span> <span class="special">*</span> <span class="special">(</span><span class="identifier">sample7</span> <span class="special">-</span> <span class="number">0.5</span> <span class="special">*</span> <span class="identifier">mu7</span><span class="special">)));</span>
<span class="special">}</span>

<span class="comment">// check for uniform distribution with weight = 1</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">weighted_p_square_quantile</span><span class="special">(</span><span class="identifier">acc0</span><span class="special">),</span> <span class="number">0.001</span><span class="special">,</span> <span class="number">15</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">weighted_p_square_quantile</span><span class="special">(</span><span class="identifier">acc1</span><span class="special">),</span> <span class="number">0.025</span><span class="special">,</span> <span class="number">5</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">weighted_p_square_quantile</span><span class="special">(</span><span class="identifier">acc2</span><span class="special">),</span> <span class="number">0.975</span><span class="special">,</span> <span class="identifier">epsilon</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">weighted_p_square_quantile</span><span class="special">(</span><span class="identifier">acc3</span><span class="special">),</span> <span class="number">0.999</span><span class="special">,</span> <span class="identifier">epsilon</span> <span class="special">);</span>

<span class="comment">// check for shifted standard normal distribution ("importance sampling")</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">weighted_p_square_quantile</span><span class="special">(</span><span class="identifier">acc4</span><span class="special">),</span> <span class="special">-</span><span class="number">3.090232</span><span class="special">,</span> <span class="identifier">epsilon</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">weighted_p_square_quantile</span><span class="special">(</span><span class="identifier">acc5</span><span class="special">),</span> <span class="special">-</span><span class="number">1.959963</span><span class="special">,</span> <span class="identifier">epsilon</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">weighted_p_square_quantile</span><span class="special">(</span><span class="identifier">acc6</span><span class="special">),</span>  <span class="number">1.959963</span><span class="special">,</span> <span class="identifier">epsilon</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">weighted_p_square_quantile</span><span class="special">(</span><span class="identifier">acc7</span><span class="special">),</span>  <span class="number">3.090232</span><span class="special">,</span> <span class="identifier">epsilon</span> <span class="special">);</span>
</pre>
<p>
          <span class="bold"><strong>See also</strong></span>
        </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
              <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/weigh_1_3_2_6_3_49_1_1_2_1.html" title="Struct template weighted_p_square_quantile_impl">weighted_p_square_quantile_impl</a></code>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.count" title="count"><code class="literal">count</code></a>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.sum" title="sum and variants"><code class="literal">sum</code></a>
            </li>
</ul></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="accumulators.user_s_guide.the_statistical_accumulators_library.weighted_peaks_over_threshold"></a><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.weighted_peaks_over_threshold" title="weighted_peaks_over_threshold and variants">weighted_peaks_over_threshold
        <span class="emphasis"><em>and variants</em></span></a>
</h4></div></div></div>
<p>
          Weighted peaks over threshold method for weighted quantile and weighted
          tail mean estimation. For more implementation details, see <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/weigh_1_3_2_6_3_50_1_1_4_1.html" title="Struct template weighted_peaks_over_threshold_impl">weighted_peaks_over_threshold_impl</a></code>
          and <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/weigh_1_3_2_6_3_50_1_1_4_2.html" title="Struct template weighted_peaks_over_threshold_prob_impl">weighted_peaks_over_threshold_prob_impl</a></code>.
        </p>
<p>
          Both <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_peaks_over_threshold</span><span class="special">&lt;</span><em class="replaceable"><code>left-or-right</code></em><span class="special">&gt;</span></code> and <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_peaks_over_threshold_prob</span><span class="special">&lt;</span><em class="replaceable"><code>left-or-right</code></em><span class="special">&gt;</span></code>
          satisfy the <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_peaks_over_threshold</span><span class="special">&lt;</span><em class="replaceable"><code>left-or-right</code></em><span class="special">&gt;</span></code> feature and can be extracted using
          the <code class="computeroutput"><span class="identifier">weighted_peaks_over_threshold</span><span class="special">()</span></code> extractor.
        </p>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Result Type</span></dt>
<dd>
<p>
                <code class="computeroutput"><span class="identifier">tuple</span><span class="special">&lt;</span><span class="identifier">float_type</span><span class="special">,</span>
                <span class="identifier">float_type</span><span class="special">,</span>
                <span class="identifier">float_type</span><span class="special">&gt;</span></code>
                where <code class="computeroutput"><span class="identifier">float_type</span></code>
                is
</p>
<pre class="programlisting"><span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">fdiv</span><span class="special">&lt;</span>
    <span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">multiplies</span><span class="special">&lt;</span><em class="replaceable"><code>sample-type</code></em><span class="special">,</span> <em class="replaceable"><code>weight-type</code></em><span class="special">&gt;::</span><span class="identifier">result_type</span>
  <span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span>
<span class="special">&gt;::</span><span class="identifier">result_type</span>
</pre>
<p>
              </p>
</dd>
<dt><span class="term">Depends On</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">weighted_peaks_over_threshold</span><span class="special">&lt;</span><em class="replaceable"><code>left-or-right</code></em><span class="special">&gt;</span></code>
                depends on <code class="computeroutput"><span class="identifier">sum_of_weights</span></code>
                <br> <code class="computeroutput"><span class="identifier">weighted_peaks_over_threshold_prob</span><span class="special">&lt;</span><em class="replaceable"><code>left-or-right</code></em><span class="special">&gt;</span></code>
                depends on <code class="computeroutput"><span class="identifier">sum_of_weights</span></code>
                and <code class="computeroutput"><span class="identifier">tail_weights</span><span class="special">&lt;</span><em class="replaceable"><code>left-or-right</code></em><span class="special">&gt;</span></code>
              </p></dd>
<dt><span class="term">Variants</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">weighted_peaks_over_threshold_prob</span></code>
              </p></dd>
<dt><span class="term">Initialization Parameters</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">peaks_over_threshold</span><span class="special">::</span><span class="identifier">threshold_value</span></code> <br> <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">peaks_over_threshold_prob</span><span class="special">::</span><span class="identifier">threshold_probability</span></code> <br> <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">tail</span><span class="special">&lt;</span><em class="replaceable"><code>left-or-right</code></em><span class="special">&gt;::</span><span class="identifier">cache_size</span></code>
              </p></dd>
<dt><span class="term">Accumulator Parameters</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">weight</span></code>
              </p></dd>
<dt><span class="term">Extractor Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Accumulator Complexity</span></dt>
<dd><p>
                TODO
              </p></dd>
<dt><span class="term">Extractor Complexity</span></dt>
<dd><p>
                O(1)
              </p></dd>
</dl>
</div>
<p>
          <span class="bold"><strong>Header</strong></span>
        </p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><code class="computeroutput"><a class="link" href="reference.html#header.boost.accumulators.statistics.weighted_peaks_over_threshold_hpp" title="Header &lt;boost/accumulators/statistics/weighted_peaks_over_threshold.hpp&gt;">boost/accumulators/statistics/weighted_peaks_over_threshold.hpp</a></code><span class="special">&gt;</span>
</pre>
<p>
          <span class="bold"><strong>See also</strong></span>
        </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
              <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/weigh_1_3_2_6_3_50_1_1_4_1.html" title="Struct template weighted_peaks_over_threshold_impl">weighted_peaks_over_threshold_impl</a></code>
            </li>
<li class="listitem">
              <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/weigh_1_3_2_6_3_50_1_1_4_2.html" title="Struct template weighted_peaks_over_threshold_prob_impl">weighted_peaks_over_threshold_prob_impl</a></code>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.sum" title="sum and variants"><code class="literal">sum</code></a>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.tail" title="tail"><code class="literal">tail</code></a>
            </li>
</ul></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="accumulators.user_s_guide.the_statistical_accumulators_library.weighted_skewness"></a><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.weighted_skewness" title="weighted_skewness">weighted_skewness</a>
</h4></div></div></div>
<p>
          The skewness of a sample distribution is defined as the ratio of the 3rd
          central moment and the <code class="literal">3/2</code>-th power of the 2nd central
          moment (the variance) of the samples 3. The skewness estimator for weighted
          samples is formally identical to the estimator for unweighted samples,
          except that the weighted counterparts of all measures it depends on are
          to be taken.
        </p>
<p>
          For implementation details, see <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/weighted_skewness_impl.html" title="Struct template weighted_skewness_impl">weighted_skewness_impl</a></code>.
        </p>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Result Type</span></dt>
<dd>
<p>
</p>
<pre class="programlisting"><span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">fdiv</span><span class="special">&lt;</span>
    <span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">multiplies</span><span class="special">&lt;</span><em class="replaceable"><code>sample-type</code></em><span class="special">,</span> <em class="replaceable"><code>weight-type</code></em><span class="special">&gt;::</span><span class="identifier">result_type</span>
  <span class="special">,</span> <span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">multiplies</span><span class="special">&lt;</span><em class="replaceable"><code>sample-type</code></em><span class="special">,</span> <em class="replaceable"><code>weight-type</code></em><span class="special">&gt;::</span><span class="identifier">result_type</span>
<span class="special">&gt;::</span><span class="identifier">result_type</span>
</pre>
<p>
              </p>
</dd>
<dt><span class="term">Depends On</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">weighted_mean</span></code> <br>
                <code class="computeroutput"><span class="identifier">weighted_moment</span><span class="special">&lt;</span><span class="number">2</span><span class="special">&gt;</span></code>
                <br> <code class="computeroutput"><span class="identifier">weighted_moment</span><span class="special">&lt;</span><span class="number">3</span><span class="special">&gt;</span></code>
              </p></dd>
<dt><span class="term">Variants</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Initialization Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Accumulator Parameters</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">weight</span></code>
              </p></dd>
<dt><span class="term">Extractor Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Accumulator Complexity</span></dt>
<dd><p>
                O(1)
              </p></dd>
<dt><span class="term">Extractor Complexity</span></dt>
<dd><p>
                O(1)
              </p></dd>
</dl>
</div>
<p>
          <span class="bold"><strong>Header</strong></span>
        </p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><code class="computeroutput"><a class="link" href="reference.html#header.boost.accumulators.statistics.weighted_skewness_hpp" title="Header &lt;boost/accumulators/statistics/weighted_skewness.hpp&gt;">boost/accumulators/statistics/weighted_skewness.hpp</a></code><span class="special">&gt;</span>
</pre>
<p>
          <span class="bold"><strong>Example</strong></span>
        </p>
<pre class="programlisting"><span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_skewness</span><span class="special">&gt;,</span> <span class="keyword">int</span> <span class="special">&gt;</span> <span class="identifier">acc2</span><span class="special">;</span>

<span class="identifier">acc2</span><span class="special">(</span><span class="number">2</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">4</span><span class="special">);</span>
<span class="identifier">acc2</span><span class="special">(</span><span class="number">7</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">1</span><span class="special">);</span>
<span class="identifier">acc2</span><span class="special">(</span><span class="number">4</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">3</span><span class="special">);</span>
<span class="identifier">acc2</span><span class="special">(</span><span class="number">9</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">1</span><span class="special">);</span>
<span class="identifier">acc2</span><span class="special">(</span><span class="number">3</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">2</span><span class="special">);</span>

<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="identifier">weighted_mean</span><span class="special">(</span><span class="identifier">acc2</span><span class="special">),</span> <span class="number">42.</span><span class="special">/</span><span class="number">11.</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="identifier">accumulators</span><span class="special">::</span><span class="identifier">weighted_moment</span><span class="special">&lt;</span><span class="number">2</span><span class="special">&gt;(</span><span class="identifier">acc2</span><span class="special">),</span> <span class="number">212.</span><span class="special">/</span><span class="number">11.</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="identifier">accumulators</span><span class="special">::</span><span class="identifier">weighted_moment</span><span class="special">&lt;</span><span class="number">3</span><span class="special">&gt;(</span><span class="identifier">acc2</span><span class="special">),</span> <span class="number">1350.</span><span class="special">/</span><span class="number">11.</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">weighted_skewness</span><span class="special">(</span><span class="identifier">acc2</span><span class="special">),</span> <span class="number">1.30708406282</span><span class="special">,</span> <span class="number">1e-6</span> <span class="special">);</span>
</pre>
<p>
          <span class="bold"><strong>See also</strong></span>
        </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
              <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/weighted_skewness_impl.html" title="Struct template weighted_skewness_impl">weighted_skewness_impl</a></code>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.weighted_mean" title="weighted_mean and variants"><code class="literal">weighted_mean</code></a>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.weighted_moment" title="weighted_moment"><code class="literal">weighted_moment</code></a>
            </li>
</ul></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="accumulators.user_s_guide.the_statistical_accumulators_library.weighted_sum"></a><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.weighted_sum" title="weighted_sum and variants">weighted_sum
        <span class="emphasis"><em>and variants</em></span></a>
</h4></div></div></div>
<p>
          For summing the weighted samples or variates. All of the <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_sum_of_variates</span><span class="special">&lt;&gt;</span></code>
          features can be extracted with the <code class="computeroutput"><span class="identifier">weighted_sum_of_variates</span><span class="special">()</span></code> extractor. Variants that implement the
          Kahan summation algorithm are also provided.
        </p>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Result Type</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">multiplies</span><span class="special">&lt;</span><em class="replaceable"><code>sample-type</code></em><span class="special">,</span> <em class="replaceable"><code>weight-type</code></em><span class="special">&gt;::</span><span class="identifier">result_type</span></code> for summing weighted
                samples <br> <code class="computeroutput"><span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">multiplies</span><span class="special">&lt;</span><em class="replaceable"><code>variate-type</code></em><span class="special">,</span> <em class="replaceable"><code>weight-type</code></em><span class="special">&gt;::</span><span class="identifier">result_type</span></code>
                for summing weighted variates
              </p></dd>
<dt><span class="term">Depends On</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Variants</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_sum</span></code> <br> <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_sum_of_variates</span><span class="special">&lt;</span><em class="replaceable"><code>variate-type</code></em><span class="special">,</span> <em class="replaceable"><code>variate-tag</code></em><span class="special">&gt;</span></code>
                <br> <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_sum_kahan</span></code> (a.k.a. tag::weighted_sum(kahan))
                <br> <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_sum_of_variates_kahan</span><span class="special">&lt;</span><em class="replaceable"><code>variate-type</code></em><span class="special">,</span> <em class="replaceable"><code>variate-tag</code></em><span class="special">&gt;</span></code> <br>
              </p></dd>
<dt><span class="term">Initialization Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Accumulator Parameters</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">weight</span></code> <br> <code class="computeroutput"><em class="replaceable"><code>variate-tag</code></em></code>
                for summing variates
              </p></dd>
<dt><span class="term">Extractor Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Accumulator Complexity</span></dt>
<dd><p>
                O(1). Note that the Kahan sum performs four floating-point sum operations
                per accumulated value, whereas the naive sum performs only one.
              </p></dd>
<dt><span class="term">Extractor Complexity</span></dt>
<dd><p>
                O(1)
              </p></dd>
</dl>
</div>
<p>
          <span class="bold"><strong>Header</strong></span>
        </p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><code class="computeroutput"><a class="link" href="reference.html#header.boost.accumulators.statistics.weighted_sum_hpp" title="Header &lt;boost/accumulators/statistics/weighted_sum.hpp&gt;">boost/accumulators/statistics/weighted_sum.hpp</a></code><span class="special">&gt;</span>
<span class="preprocessor">#include</span> <span class="special">&lt;</span><code class="computeroutput"><a class="link" href="reference.html#header.boost.accumulators.statistics.weighted_sum_kahan_hpp" title="Header &lt;boost/accumulators/statistics/weighted_sum_kahan.hpp&gt;">boost/accumulators/statistics/weighted_sum_kahan.hpp</a></code><span class="special">&gt;</span>
</pre>
<p>
          <span class="bold"><strong>Example</strong></span>
        </p>
<pre class="programlisting"><span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_sum</span><span class="special">,</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_sum_of_variates</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">,</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">covariate1</span><span class="special">&gt;</span> <span class="special">&gt;,</span> <span class="keyword">int</span><span class="special">&gt;</span> <span class="identifier">acc</span><span class="special">;</span>

<span class="identifier">acc</span><span class="special">(</span><span class="number">1</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">2</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="number">3</span><span class="special">);</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span><span class="number">2</span><span class="special">,</span> <span class="identifier">weighted_sum</span><span class="special">(</span><span class="identifier">acc</span><span class="special">));</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span><span class="number">6</span><span class="special">,</span> <span class="identifier">weighted_sum_of_variates</span><span class="special">(</span><span class="identifier">acc</span><span class="special">));</span>

<span class="identifier">acc</span><span class="special">(</span><span class="number">2</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">3</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="number">6</span><span class="special">);</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span><span class="number">8</span><span class="special">,</span> <span class="identifier">weighted_sum</span><span class="special">(</span><span class="identifier">acc</span><span class="special">));</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span><span class="number">24</span><span class="special">,</span> <span class="identifier">weighted_sum_of_variates</span><span class="special">(</span><span class="identifier">acc</span><span class="special">));</span>

<span class="identifier">acc</span><span class="special">(</span><span class="number">4</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">6</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="number">9</span><span class="special">);</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span><span class="number">32</span><span class="special">,</span> <span class="identifier">weighted_sum</span><span class="special">(</span><span class="identifier">acc</span><span class="special">));</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span><span class="number">78</span><span class="special">,</span> <span class="identifier">weighted_sum_of_variates</span><span class="special">(</span><span class="identifier">acc</span><span class="special">));</span>

<span class="comment">// demonstrate weighted Kahan summation</span>
<span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">float</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_sum_kahan</span><span class="special">&gt;,</span> <span class="keyword">float</span> <span class="special">&gt;</span> <span class="identifier">acc</span><span class="special">;</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span><span class="number">0.0f</span><span class="special">,</span> <span class="identifier">weighted_sum_kahan</span><span class="special">(</span><span class="identifier">acc</span><span class="special">));</span>
<span class="keyword">for</span> <span class="special">(</span><span class="identifier">size_t</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special">&lt;</span> <span class="number">1e6</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span> <span class="special">{</span>
  <span class="identifier">acc</span><span class="special">(</span><span class="number">1.0f</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">1e-6f</span><span class="special">);</span>
<span class="special">}</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span><span class="number">1.0f</span><span class="special">,</span> <span class="identifier">weighted_sum_kahan</span><span class="special">(</span><span class="identifier">acc</span><span class="special">));</span>
</pre>
<p>
          <span class="bold"><strong>See also</strong></span>
        </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
              <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/weighted_sum_impl.html" title="Struct template weighted_sum_impl">weighted_sum_impl</a></code>
            </li>
<li class="listitem">
              <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/weighted_sum_impl.html" title="Struct template weighted_sum_impl">weighted_sum_kahan_impl</a></code>
            </li>
</ul></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="accumulators.user_s_guide.the_statistical_accumulators_library.non_coherent_weighted_tail_mean"></a><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.non_coherent_weighted_tail_mean" title="non_coherent_weighted_tail_mean">non_coherent_weighted_tail_mean</a>
</h4></div></div></div>
<p>
          Estimation of the (non-coherent) weighted tail mean based on order statistics
          (for both left and right tails). The left non-coherent weighted tail mean
          feature is <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">non_coherent_weighted_tail_mean</span><span class="special">&lt;</span><span class="identifier">left</span><span class="special">&gt;</span></code>,
          and the right non-choherent weighted tail mean feature is <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">non_coherent_weighted_tail_mean</span><span class="special">&lt;</span><span class="identifier">right</span><span class="special">&gt;</span></code>.
          They both share the <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">abstract_non_coherent_tail_mean</span></code>
          feature with the unweighted non-coherent tail mean accumulators and can
          be extracted with either the <code class="computeroutput"><span class="identifier">non_coherent_tail_mean</span><span class="special">()</span></code> or the <code class="computeroutput"><span class="identifier">non_coherent_weighted_tail_mean</span><span class="special">()</span></code> extractors. For more implementation details,
          see <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/non_c_1_3_2_6_3_54_1_1_2_1.html" title="Struct template non_coherent_weighted_tail_mean_impl">non_coherent_weighted_tail_mean_impl</a></code>.
        </p>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Result Type</span></dt>
<dd>
<p>
</p>
<pre class="programlisting"><span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">fdiv</span><span class="special">&lt;</span>
    <span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">multiplies</span><span class="special">&lt;</span><em class="replaceable"><code>sample-type</code></em><span class="special">,</span> <em class="replaceable"><code>weight-type</code></em><span class="special">&gt;::</span><span class="identifier">result_type</span>
  <span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span>
<span class="special">&gt;::</span><span class="identifier">result_type</span>
</pre>
<p>
              </p>
</dd>
<dt><span class="term">Depends On</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">sum_of_weights</span></code> <br>
                <code class="computeroutput"><span class="identifier">tail_weights</span><span class="special">&lt;</span><em class="replaceable"><code>left-or-right</code></em><span class="special">&gt;</span></code>
              </p></dd>
<dt><span class="term">Variants</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">abstract_non_coherent_tail_mean</span></code>
              </p></dd>
<dt><span class="term">Initialization Parameters</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">tail</span><span class="special">&lt;</span><em class="replaceable"><code>left-or-right</code></em><span class="special">&gt;::</span><span class="identifier">cache_size</span></code>
              </p></dd>
<dt><span class="term">Accumulator Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Extractor Parameters</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">quantile_probability</span></code>
              </p></dd>
<dt><span class="term">Accumulator Complexity</span></dt>
<dd><p>
                O(log N), where N is the cache size
              </p></dd>
<dt><span class="term">Extractor Complexity</span></dt>
<dd><p>
                O(N log N), where N is the cache size
              </p></dd>
</dl>
</div>
<p>
          <span class="bold"><strong>Header</strong></span>
        </p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><code class="computeroutput"><a class="link" href="reference.html#header.boost.accumulators.statistics.weighted_tail_mean_hpp" title="Header &lt;boost/accumulators/statistics/weighted_tail_mean.hpp&gt;">boost/accumulators/statistics/weighted_tail_mean.hpp</a></code><span class="special">&gt;</span>
</pre>
<p>
          <span class="bold"><strong>Example</strong></span>
        </p>
<pre class="programlisting"><span class="comment">// tolerance in %</span>
<span class="keyword">double</span> <span class="identifier">epsilon</span> <span class="special">=</span> <span class="number">1</span><span class="special">;</span>

<span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">n</span> <span class="special">=</span> <span class="number">100000</span><span class="special">;</span> <span class="comment">// number of MC steps</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">c</span> <span class="special">=</span> <span class="number">25000</span><span class="special">;</span> <span class="comment">// cache size</span>

<span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">non_coherent_weighted_tail_mean</span><span class="special">&lt;</span><span class="identifier">right</span><span class="special">&gt;</span> <span class="special">&gt;,</span> <span class="keyword">double</span> <span class="special">&gt;</span>
    <span class="identifier">acc0</span><span class="special">(</span> <span class="identifier">right_tail_cache_size</span> <span class="special">=</span> <span class="identifier">c</span> <span class="special">);</span>
<span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">non_coherent_weighted_tail_mean</span><span class="special">&lt;</span><span class="identifier">left</span><span class="special">&gt;</span> <span class="special">&gt;,</span> <span class="keyword">double</span> <span class="special">&gt;</span>
    <span class="identifier">acc1</span><span class="special">(</span> <span class="identifier">left_tail_cache_size</span> <span class="special">=</span> <span class="identifier">c</span> <span class="special">);</span>

<span class="comment">// random number generators</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">lagged_fibonacci607</span> <span class="identifier">rng</span><span class="special">;</span>

<span class="keyword">for</span> <span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special">&lt;</span> <span class="identifier">n</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
<span class="special">{</span>
    <span class="keyword">double</span> <span class="identifier">smpl</span> <span class="special">=</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">sqrt</span><span class="special">(</span><span class="identifier">rng</span><span class="special">());</span>
    <span class="identifier">acc0</span><span class="special">(</span><span class="identifier">smpl</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">1.</span><span class="special">/</span><span class="identifier">smpl</span><span class="special">);</span>
<span class="special">}</span>

<span class="keyword">for</span> <span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special">&lt;</span> <span class="identifier">n</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
<span class="special">{</span>
    <span class="keyword">double</span> <span class="identifier">smpl</span> <span class="special">=</span> <span class="identifier">rng</span><span class="special">();</span>
    <span class="identifier">acc1</span><span class="special">(</span><span class="identifier">smpl</span><span class="special">*</span><span class="identifier">smpl</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="identifier">smpl</span><span class="special">);</span>
<span class="special">}</span>

<span class="comment">// check uniform distribution</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">non_coherent_weighted_tail_mean</span><span class="special">(</span><span class="identifier">acc0</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.95</span><span class="special">),</span> <span class="number">0.975</span><span class="special">,</span> <span class="identifier">epsilon</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">non_coherent_weighted_tail_mean</span><span class="special">(</span><span class="identifier">acc0</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.975</span><span class="special">),</span> <span class="number">0.9875</span><span class="special">,</span> <span class="identifier">epsilon</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">non_coherent_weighted_tail_mean</span><span class="special">(</span><span class="identifier">acc0</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.99</span><span class="special">),</span> <span class="number">0.995</span><span class="special">,</span> <span class="identifier">epsilon</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">non_coherent_weighted_tail_mean</span><span class="special">(</span><span class="identifier">acc0</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.999</span><span class="special">),</span> <span class="number">0.9995</span><span class="special">,</span> <span class="identifier">epsilon</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">non_coherent_weighted_tail_mean</span><span class="special">(</span><span class="identifier">acc1</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.05</span><span class="special">),</span> <span class="number">0.025</span><span class="special">,</span> <span class="identifier">epsilon</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">non_coherent_weighted_tail_mean</span><span class="special">(</span><span class="identifier">acc1</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.025</span><span class="special">),</span> <span class="number">0.0125</span><span class="special">,</span> <span class="identifier">epsilon</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">non_coherent_weighted_tail_mean</span><span class="special">(</span><span class="identifier">acc1</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.01</span><span class="special">),</span> <span class="number">0.005</span><span class="special">,</span> <span class="identifier">epsilon</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">non_coherent_weighted_tail_mean</span><span class="special">(</span><span class="identifier">acc1</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.001</span><span class="special">),</span> <span class="number">0.0005</span><span class="special">,</span> <span class="number">5</span><span class="special">*</span><span class="identifier">epsilon</span> <span class="special">);</span>
</pre>
<p>
          <span class="bold"><strong>See also</strong></span>
        </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
              <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/non_c_1_3_2_6_3_54_1_1_2_1.html" title="Struct template non_coherent_weighted_tail_mean_impl">non_coherent_weighted_tail_mean_impl</a></code>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.sum" title="sum and variants"><code class="literal">sum</code></a>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.tail" title="tail"><code class="literal">tail</code></a>
            </li>
</ul></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="accumulators.user_s_guide.the_statistical_accumulators_library.weighted_tail_quantile"></a><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.weighted_tail_quantile" title="weighted_tail_quantile">weighted_tail_quantile</a>
</h4></div></div></div>
<p>
          Tail quantile estimation based on order statistics of weighted samples
          (for both left and right tails). The left weighted tail quantile feature
          is <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_tail_quantile</span><span class="special">&lt;</span><span class="identifier">left</span><span class="special">&gt;</span></code>,
          and the right weighted tail quantile feature is <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_tail_quantile</span><span class="special">&lt;</span><span class="identifier">right</span><span class="special">&gt;</span></code>. They both share the <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">quantile</span></code> feature with the unweighted
          tail quantile accumulators and can be extracted with either the <code class="computeroutput"><span class="identifier">quantile</span><span class="special">()</span></code>
          or the <code class="computeroutput"><span class="identifier">weighted_tail_quantile</span><span class="special">()</span></code> extractors. For more implementation details,
          see <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/weigh_1_3_2_6_3_55_1_1_2_1.html" title="Struct template weighted_tail_quantile_impl">weighted_tail_quantile_impl</a></code>
        </p>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Result Type</span></dt>
<dd>
<p>
</p>
<pre class="programlisting"><em class="replaceable"><code>sample-type</code></em>
</pre>
<p>
              </p>
</dd>
<dt><span class="term">Depends On</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">sum_of_weights</span></code> <br>
                <code class="computeroutput"><span class="identifier">tail_weights</span><span class="special">&lt;</span><em class="replaceable"><code>left-or-right</code></em><span class="special">&gt;</span></code>
              </p></dd>
<dt><span class="term">Variants</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Initialization Parameters</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">tail</span><span class="special">&lt;</span><em class="replaceable"><code>left-or-right</code></em><span class="special">&gt;::</span><span class="identifier">cache_size</span></code>
              </p></dd>
<dt><span class="term">Accumulator Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Extractor Parameters</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">quantile_probability</span></code>
              </p></dd>
<dt><span class="term">Accumulator Complexity</span></dt>
<dd><p>
                O(log N), where N is the cache size
              </p></dd>
<dt><span class="term">Extractor Complexity</span></dt>
<dd><p>
                O(N log N), where N is the cache size
              </p></dd>
</dl>
</div>
<p>
          <span class="bold"><strong>Header</strong></span>
        </p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><code class="computeroutput"><a class="link" href="reference.html#header.boost.accumulators.statistics.weighted_tail_quantile_hpp" title="Header &lt;boost/accumulators/statistics/weighted_tail_quantile.hpp&gt;">boost/accumulators/statistics/weighted_tail_quantile.hpp</a></code><span class="special">&gt;</span>
</pre>
<p>
          <span class="bold"><strong>Example</strong></span>
        </p>
<pre class="programlisting"><span class="comment">// tolerance in %</span>
<span class="keyword">double</span> <span class="identifier">epsilon</span> <span class="special">=</span> <span class="number">1</span><span class="special">;</span>

<span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">n</span> <span class="special">=</span> <span class="number">100000</span><span class="special">;</span> <span class="comment">// number of MC steps</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">c</span> <span class="special">=</span>  <span class="number">20000</span><span class="special">;</span> <span class="comment">// cache size</span>

<span class="keyword">double</span> <span class="identifier">mu1</span> <span class="special">=</span> <span class="number">1.0</span><span class="special">;</span>
<span class="keyword">double</span> <span class="identifier">mu2</span> <span class="special">=</span> <span class="special">-</span><span class="number">1.0</span><span class="special">;</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">lagged_fibonacci607</span> <span class="identifier">rng</span><span class="special">;</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">normal_distribution</span><span class="special">&lt;&gt;</span> <span class="identifier">mean_sigma1</span><span class="special">(</span><span class="identifier">mu1</span><span class="special">,</span><span class="number">1</span><span class="special">);</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">normal_distribution</span><span class="special">&lt;&gt;</span> <span class="identifier">mean_sigma2</span><span class="special">(</span><span class="identifier">mu2</span><span class="special">,</span><span class="number">1</span><span class="special">);</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">variate_generator</span><span class="special">&lt;</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">lagged_fibonacci607</span><span class="special">&amp;,</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">normal_distribution</span><span class="special">&lt;&gt;</span> <span class="special">&gt;</span> <span class="identifier">normal1</span><span class="special">(</span><span class="identifier">rng</span><span class="special">,</span> <span class="identifier">mean_sigma1</span><span class="special">);</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">variate_generator</span><span class="special">&lt;</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">lagged_fibonacci607</span><span class="special">&amp;,</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">normal_distribution</span><span class="special">&lt;&gt;</span> <span class="special">&gt;</span> <span class="identifier">normal2</span><span class="special">(</span><span class="identifier">rng</span><span class="special">,</span> <span class="identifier">mean_sigma2</span><span class="special">);</span>

<span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_tail_quantile</span><span class="special">&lt;</span><span class="identifier">right</span><span class="special">&gt;</span> <span class="special">&gt;,</span> <span class="keyword">double</span><span class="special">&gt;</span>
    <span class="identifier">acc1</span><span class="special">(</span><span class="identifier">right_tail_cache_size</span> <span class="special">=</span> <span class="identifier">c</span><span class="special">);</span>

<span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_tail_quantile</span><span class="special">&lt;</span><span class="identifier">left</span><span class="special">&gt;</span> <span class="special">&gt;,</span> <span class="keyword">double</span><span class="special">&gt;</span>
    <span class="identifier">acc2</span><span class="special">(</span><span class="identifier">left_tail_cache_size</span> <span class="special">=</span> <span class="identifier">c</span><span class="special">);</span>

<span class="keyword">for</span> <span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special">&lt;</span> <span class="identifier">n</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
<span class="special">{</span>
    <span class="keyword">double</span> <span class="identifier">sample1</span> <span class="special">=</span> <span class="identifier">normal1</span><span class="special">();</span>
    <span class="keyword">double</span> <span class="identifier">sample2</span> <span class="special">=</span> <span class="identifier">normal2</span><span class="special">();</span>
    <span class="identifier">acc1</span><span class="special">(</span><span class="identifier">sample1</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">exp</span><span class="special">(-</span><span class="identifier">mu1</span> <span class="special">*</span> <span class="special">(</span><span class="identifier">sample1</span> <span class="special">-</span> <span class="number">0.5</span> <span class="special">*</span> <span class="identifier">mu1</span><span class="special">)));</span>
    <span class="identifier">acc2</span><span class="special">(</span><span class="identifier">sample2</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">exp</span><span class="special">(-</span><span class="identifier">mu2</span> <span class="special">*</span> <span class="special">(</span><span class="identifier">sample2</span> <span class="special">-</span> <span class="number">0.5</span> <span class="special">*</span> <span class="identifier">mu2</span><span class="special">)));</span>
<span class="special">}</span>

<span class="comment">// check standard normal distribution</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">quantile</span><span class="special">(</span><span class="identifier">acc1</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.975</span><span class="special">),</span>  <span class="number">1.959963</span><span class="special">,</span> <span class="identifier">epsilon</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">quantile</span><span class="special">(</span><span class="identifier">acc1</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.999</span><span class="special">),</span>  <span class="number">3.090232</span><span class="special">,</span> <span class="identifier">epsilon</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">quantile</span><span class="special">(</span><span class="identifier">acc2</span><span class="special">,</span> <span class="identifier">quantile_probability</span>  <span class="special">=</span> <span class="number">0.025</span><span class="special">),</span> <span class="special">-</span><span class="number">1.959963</span><span class="special">,</span> <span class="identifier">epsilon</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span> <span class="identifier">quantile</span><span class="special">(</span><span class="identifier">acc2</span><span class="special">,</span> <span class="identifier">quantile_probability</span>  <span class="special">=</span> <span class="number">0.001</span><span class="special">),</span> <span class="special">-</span><span class="number">3.090232</span><span class="special">,</span> <span class="identifier">epsilon</span> <span class="special">);</span>
</pre>
<p>
          <span class="bold"><strong>See also</strong></span>
        </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
              <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/weigh_1_3_2_6_3_55_1_1_2_1.html" title="Struct template weighted_tail_quantile_impl">weighted_tail_quantile_impl</a></code>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.sum" title="sum and variants"><code class="literal">sum</code></a>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.tail" title="tail"><code class="literal">tail</code></a>
            </li>
</ul></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="accumulators.user_s_guide.the_statistical_accumulators_library.weighted_tail_variate_means"></a><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.weighted_tail_variate_means" title="weighted_tail_variate_means and variants">weighted_tail_variate_means
        <span class="emphasis"><em>and variants</em></span></a>
</h4></div></div></div>
<p>
          Estimation of the absolute and relative weighted tail variate means (for
          both left and right tails) The absolute weighted tail variate means has
          the feature <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">absolute_weighted_tail_variate_means</span><span class="special">&lt;</span><em class="replaceable"><code>left-or-right</code></em><span class="special">,</span> <em class="replaceable"><code>variate-type</code></em><span class="special">,</span>
          <em class="replaceable"><code>variate-tag</code></em><span class="special">&gt;</span></code> and the relative weighted tail
          variate mean has the feature <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">relative_weighted_tail_variate_means</span><span class="special">&lt;</span><em class="replaceable"><code>left-or-right</code></em><span class="special">,</span> <em class="replaceable"><code>variate-type</code></em><span class="special">,</span>
          <em class="replaceable"><code>variate-tag</code></em><span class="special">&gt;</span></code>. All absolute weighted tail
          variate mean features share the <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">abstract_absolute_tail_variate_means</span></code>
          feature with their unweighted variants and can be extracted with the <code class="computeroutput"><span class="identifier">tail_variate_means</span><span class="special">()</span></code>
          and <code class="computeroutput"><span class="identifier">weighted_tail_variate_means</span><span class="special">()</span></code> extractors. All the relative weighted
          tail variate mean features share the <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">abstract_relative_tail_variate_means</span></code>
          feature with their unweighted variants and can be extracted with either
          the <code class="computeroutput"><span class="identifier">relative_tail_variate_means</span><span class="special">()</span></code> or <code class="computeroutput"><span class="identifier">relative_weighted_tail_variate_means</span><span class="special">()</span></code> extractors.
        </p>
<p>
          For more implementation details, see <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/weigh_1_3_2_6_3_56_1_1_4_1.html" title="Struct template weighted_tail_variate_means_impl">weighted_tail_variate_means_impl</a></code>
        </p>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Result Type</span></dt>
<dd>
<p>
</p>
<pre class="programlisting"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">iterator_range</span><span class="special">&lt;</span>
    <span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">fdiv</span><span class="special">&lt;</span>
        <span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">multiplies</span><span class="special">&lt;</span><em class="replaceable"><code>variate-type</code></em><span class="special">,</span> <em class="replaceable"><code>weight-type</code></em><span class="special">&gt;::</span><span class="identifier">result_type</span>
      <span class="special">,</span> <em class="replaceable"><code>weight-type</code></em>
    <span class="special">&gt;::</span><span class="identifier">result_type</span><span class="special">::</span><span class="identifier">iterator</span>
<span class="special">&gt;</span>
</pre>
<p>
              </p>
</dd>
<dt><span class="term">Depends On</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">non_coherent_weighted_tail_mean</span><span class="special">&lt;</span><em class="replaceable"><code>left-or-right</code></em><span class="special">&gt;</span></code>
                <br> <code class="computeroutput"><span class="identifier">tail_variate</span><span class="special">&lt;</span><em class="replaceable"><code>variate-type</code></em><span class="special">,</span> <em class="replaceable"><code>variate-tag</code></em><span class="special">,</span> <em class="replaceable"><code>left-or-right</code></em><span class="special">&gt;</span></code>
                <br> <code class="computeroutput"><span class="identifier">tail_weights</span><span class="special">&lt;</span><em class="replaceable"><code>left-or-right</code></em><span class="special">&gt;</span></code>
              </p></dd>
<dt><span class="term">Variants</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">absolute_weighted_tail_variate_means</span><span class="special">&lt;</span><em class="replaceable"><code>left-or-right</code></em><span class="special">,</span> <em class="replaceable"><code>variate-type</code></em><span class="special">,</span> <em class="replaceable"><code>variate-tag</code></em><span class="special">&gt;</span></code>
                <br> <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">relative_weighted_tail_variate_means</span><span class="special">&lt;</span><em class="replaceable"><code>left-or-right</code></em><span class="special">,</span> <em class="replaceable"><code>variate-type</code></em><span class="special">,</span> <em class="replaceable"><code>variate-tag</code></em><span class="special">&gt;</span></code>
              </p></dd>
<dt><span class="term">Initialization Parameters</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">tail</span><span class="special">&lt;</span><em class="replaceable"><code>left-or-right</code></em><span class="special">&gt;::</span><span class="identifier">cache_size</span></code>
              </p></dd>
<dt><span class="term">Accumulator Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Extractor Parameters</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">quantile_probability</span></code>
              </p></dd>
<dt><span class="term">Accumulator Complexity</span></dt>
<dd><p>
                O(log N), where N is the cache size
              </p></dd>
<dt><span class="term">Extractor Complexity</span></dt>
<dd><p>
                O(N log N), where N is the cache size
              </p></dd>
</dl>
</div>
<p>
          <span class="bold"><strong>Header</strong></span>
        </p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><code class="computeroutput"><a class="link" href="reference.html#header.boost.accumulators.statistics.weighted_tail_variate_means_hpp" title="Header &lt;boost/accumulators/statistics/weighted_tail_variate_means.hpp&gt;">boost/accumulators/statistics/weighted_tail_variate_means.hpp</a></code><span class="special">&gt;</span>
</pre>
<p>
          <span class="bold"><strong>Example</strong></span>
        </p>
<pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">c</span> <span class="special">=</span> <span class="number">5</span><span class="special">;</span> <span class="comment">// cache size</span>

<span class="keyword">typedef</span> <span class="keyword">double</span> <span class="identifier">variate_type</span><span class="special">;</span>
<span class="keyword">typedef</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span><span class="identifier">variate_type</span><span class="special">&gt;</span> <span class="identifier">variate_set_type</span><span class="special">;</span>

<span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_tail_variate_means</span><span class="special">&lt;</span><span class="identifier">right</span><span class="special">,</span> <span class="identifier">variate_set_type</span><span class="special">,</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">covariate1</span><span class="special">&gt;(</span><span class="identifier">relative</span><span class="special">)&gt;,</span> <span class="keyword">double</span> <span class="special">&gt;</span>
    <span class="identifier">acc1</span><span class="special">(</span> <span class="identifier">right_tail_cache_size</span> <span class="special">=</span> <span class="identifier">c</span> <span class="special">);</span>
<span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_tail_variate_means</span><span class="special">&lt;</span><span class="identifier">right</span><span class="special">,</span> <span class="identifier">variate_set_type</span><span class="special">,</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">covariate1</span><span class="special">&gt;(</span><span class="identifier">absolute</span><span class="special">)&gt;,</span> <span class="keyword">double</span> <span class="special">&gt;</span>
    <span class="identifier">acc2</span><span class="special">(</span> <span class="identifier">right_tail_cache_size</span> <span class="special">=</span> <span class="identifier">c</span> <span class="special">);</span>
<span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_tail_variate_means</span><span class="special">&lt;</span><span class="identifier">left</span><span class="special">,</span> <span class="identifier">variate_set_type</span><span class="special">,</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">covariate1</span><span class="special">&gt;(</span><span class="identifier">relative</span><span class="special">)&gt;,</span> <span class="keyword">double</span> <span class="special">&gt;</span>
    <span class="identifier">acc3</span><span class="special">(</span> <span class="identifier">left_tail_cache_size</span> <span class="special">=</span> <span class="identifier">c</span> <span class="special">);</span>
<span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_tail_variate_means</span><span class="special">&lt;</span><span class="identifier">left</span><span class="special">,</span> <span class="identifier">variate_set_type</span><span class="special">,</span> <span class="identifier">tag</span><span class="special">::</span><span class="identifier">covariate1</span><span class="special">&gt;(</span><span class="identifier">absolute</span><span class="special">)&gt;,</span> <span class="keyword">double</span> <span class="special">&gt;</span>
    <span class="identifier">acc4</span><span class="special">(</span> <span class="identifier">left_tail_cache_size</span> <span class="special">=</span> <span class="identifier">c</span> <span class="special">);</span>

<span class="identifier">variate_set_type</span> <span class="identifier">cov1</span><span class="special">,</span> <span class="identifier">cov2</span><span class="special">,</span> <span class="identifier">cov3</span><span class="special">,</span> <span class="identifier">cov4</span><span class="special">,</span> <span class="identifier">cov5</span><span class="special">;</span>
<span class="keyword">double</span> <span class="identifier">c1</span><span class="special">[]</span> <span class="special">=</span> <span class="special">{</span> <span class="number">10.</span><span class="special">,</span> <span class="number">20.</span><span class="special">,</span> <span class="number">30.</span><span class="special">,</span> <span class="number">40.</span> <span class="special">};</span> <span class="comment">// 100</span>
<span class="keyword">double</span> <span class="identifier">c2</span><span class="special">[]</span> <span class="special">=</span> <span class="special">{</span> <span class="number">26.</span><span class="special">,</span>  <span class="number">4.</span><span class="special">,</span> <span class="number">17.</span><span class="special">,</span>  <span class="number">3.</span> <span class="special">};</span> <span class="comment">// 50</span>
<span class="keyword">double</span> <span class="identifier">c3</span><span class="special">[]</span> <span class="special">=</span> <span class="special">{</span> <span class="number">46.</span><span class="special">,</span> <span class="number">64.</span><span class="special">,</span> <span class="number">40.</span><span class="special">,</span> <span class="number">50.</span> <span class="special">};</span> <span class="comment">// 200</span>
<span class="keyword">double</span> <span class="identifier">c4</span><span class="special">[]</span> <span class="special">=</span> <span class="special">{</span>  <span class="number">1.</span><span class="special">,</span>  <span class="number">3.</span><span class="special">,</span> <span class="number">70.</span><span class="special">,</span>  <span class="number">6.</span> <span class="special">};</span> <span class="comment">// 80</span>
<span class="keyword">double</span> <span class="identifier">c5</span><span class="special">[]</span> <span class="special">=</span> <span class="special">{</span>  <span class="number">2.</span><span class="special">,</span>  <span class="number">2.</span><span class="special">,</span>  <span class="number">2.</span><span class="special">,</span> <span class="number">14.</span> <span class="special">};</span> <span class="comment">// 20</span>
<span class="identifier">cov1</span><span class="special">.</span><span class="identifier">assign</span><span class="special">(</span><span class="identifier">c1</span><span class="special">,</span> <span class="identifier">c1</span> <span class="special">+</span> <span class="keyword">sizeof</span><span class="special">(</span><span class="identifier">c1</span><span class="special">)/</span><span class="keyword">sizeof</span><span class="special">(</span><span class="identifier">variate_type</span><span class="special">));</span>
<span class="identifier">cov2</span><span class="special">.</span><span class="identifier">assign</span><span class="special">(</span><span class="identifier">c2</span><span class="special">,</span> <span class="identifier">c2</span> <span class="special">+</span> <span class="keyword">sizeof</span><span class="special">(</span><span class="identifier">c2</span><span class="special">)/</span><span class="keyword">sizeof</span><span class="special">(</span><span class="identifier">variate_type</span><span class="special">));</span>
<span class="identifier">cov3</span><span class="special">.</span><span class="identifier">assign</span><span class="special">(</span><span class="identifier">c3</span><span class="special">,</span> <span class="identifier">c3</span> <span class="special">+</span> <span class="keyword">sizeof</span><span class="special">(</span><span class="identifier">c3</span><span class="special">)/</span><span class="keyword">sizeof</span><span class="special">(</span><span class="identifier">variate_type</span><span class="special">));</span>
<span class="identifier">cov4</span><span class="special">.</span><span class="identifier">assign</span><span class="special">(</span><span class="identifier">c4</span><span class="special">,</span> <span class="identifier">c4</span> <span class="special">+</span> <span class="keyword">sizeof</span><span class="special">(</span><span class="identifier">c4</span><span class="special">)/</span><span class="keyword">sizeof</span><span class="special">(</span><span class="identifier">variate_type</span><span class="special">));</span>
<span class="identifier">cov5</span><span class="special">.</span><span class="identifier">assign</span><span class="special">(</span><span class="identifier">c5</span><span class="special">,</span> <span class="identifier">c5</span> <span class="special">+</span> <span class="keyword">sizeof</span><span class="special">(</span><span class="identifier">c5</span><span class="special">)/</span><span class="keyword">sizeof</span><span class="special">(</span><span class="identifier">variate_type</span><span class="special">));</span>

<span class="identifier">acc1</span><span class="special">(</span><span class="number">100.</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">0.8</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="identifier">cov1</span><span class="special">);</span>
<span class="identifier">acc1</span><span class="special">(</span> <span class="number">50.</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">0.9</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="identifier">cov2</span><span class="special">);</span>
<span class="identifier">acc1</span><span class="special">(</span><span class="number">200.</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">1.0</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="identifier">cov3</span><span class="special">);</span>
<span class="identifier">acc1</span><span class="special">(</span> <span class="number">80.</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">1.1</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="identifier">cov4</span><span class="special">);</span>
<span class="identifier">acc1</span><span class="special">(</span> <span class="number">20.</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">1.2</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="identifier">cov5</span><span class="special">);</span>

<span class="identifier">acc2</span><span class="special">(</span><span class="number">100.</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">0.8</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="identifier">cov1</span><span class="special">);</span>
<span class="identifier">acc2</span><span class="special">(</span> <span class="number">50.</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">0.9</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="identifier">cov2</span><span class="special">);</span>
<span class="identifier">acc2</span><span class="special">(</span><span class="number">200.</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">1.0</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="identifier">cov3</span><span class="special">);</span>
<span class="identifier">acc2</span><span class="special">(</span> <span class="number">80.</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">1.1</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="identifier">cov4</span><span class="special">);</span>
<span class="identifier">acc2</span><span class="special">(</span> <span class="number">20.</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">1.2</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="identifier">cov5</span><span class="special">);</span>

<span class="identifier">acc3</span><span class="special">(</span><span class="number">100.</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">0.8</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="identifier">cov1</span><span class="special">);</span>
<span class="identifier">acc3</span><span class="special">(</span> <span class="number">50.</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">0.9</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="identifier">cov2</span><span class="special">);</span>
<span class="identifier">acc3</span><span class="special">(</span><span class="number">200.</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">1.0</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="identifier">cov3</span><span class="special">);</span>
<span class="identifier">acc3</span><span class="special">(</span> <span class="number">80.</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">1.1</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="identifier">cov4</span><span class="special">);</span>
<span class="identifier">acc3</span><span class="special">(</span> <span class="number">20.</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">1.2</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="identifier">cov5</span><span class="special">);</span>

<span class="identifier">acc4</span><span class="special">(</span><span class="number">100.</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">0.8</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="identifier">cov1</span><span class="special">);</span>
<span class="identifier">acc4</span><span class="special">(</span> <span class="number">50.</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">0.9</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="identifier">cov2</span><span class="special">);</span>
<span class="identifier">acc4</span><span class="special">(</span><span class="number">200.</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">1.0</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="identifier">cov3</span><span class="special">);</span>
<span class="identifier">acc4</span><span class="special">(</span> <span class="number">80.</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">1.1</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="identifier">cov4</span><span class="special">);</span>
<span class="identifier">acc4</span><span class="special">(</span> <span class="number">20.</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">1.2</span><span class="special">,</span> <span class="identifier">covariate1</span> <span class="special">=</span> <span class="identifier">cov5</span><span class="special">);</span>

<span class="comment">// check relative risk contributions</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="special">*(</span><span class="identifier">relative_weighted_tail_variate_means</span><span class="special">(</span><span class="identifier">acc1</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.7</span><span class="special">).</span><span class="identifier">begin</span><span class="special">()</span>    <span class="special">),</span> <span class="special">(</span><span class="number">0.8</span><span class="special">*</span><span class="number">10</span> <span class="special">+</span> <span class="number">1.0</span><span class="special">*</span><span class="number">46</span><span class="special">)/(</span><span class="number">0.8</span><span class="special">*</span><span class="number">100</span> <span class="special">+</span> <span class="number">1.0</span><span class="special">*</span><span class="number">200</span><span class="special">)</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="special">*(</span><span class="identifier">relative_weighted_tail_variate_means</span><span class="special">(</span><span class="identifier">acc1</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.7</span><span class="special">).</span><span class="identifier">begin</span><span class="special">()</span> <span class="special">+</span> <span class="number">1</span><span class="special">),</span> <span class="special">(</span><span class="number">0.8</span><span class="special">*</span><span class="number">20</span> <span class="special">+</span> <span class="number">1.0</span><span class="special">*</span><span class="number">64</span><span class="special">)/(</span><span class="number">0.8</span><span class="special">*</span><span class="number">100</span> <span class="special">+</span> <span class="number">1.0</span><span class="special">*</span><span class="number">200</span><span class="special">)</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="special">*(</span><span class="identifier">relative_weighted_tail_variate_means</span><span class="special">(</span><span class="identifier">acc1</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.7</span><span class="special">).</span><span class="identifier">begin</span><span class="special">()</span> <span class="special">+</span> <span class="number">2</span><span class="special">),</span> <span class="special">(</span><span class="number">0.8</span><span class="special">*</span><span class="number">30</span> <span class="special">+</span> <span class="number">1.0</span><span class="special">*</span><span class="number">40</span><span class="special">)/(</span><span class="number">0.8</span><span class="special">*</span><span class="number">100</span> <span class="special">+</span> <span class="number">1.0</span><span class="special">*</span><span class="number">200</span><span class="special">)</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="special">*(</span><span class="identifier">relative_weighted_tail_variate_means</span><span class="special">(</span><span class="identifier">acc1</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.7</span><span class="special">).</span><span class="identifier">begin</span><span class="special">()</span> <span class="special">+</span> <span class="number">3</span><span class="special">),</span> <span class="special">(</span><span class="number">0.8</span><span class="special">*</span><span class="number">40</span> <span class="special">+</span> <span class="number">1.0</span><span class="special">*</span><span class="number">50</span><span class="special">)/(</span><span class="number">0.8</span><span class="special">*</span><span class="number">100</span> <span class="special">+</span> <span class="number">1.0</span><span class="special">*</span><span class="number">200</span><span class="special">)</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="special">*(</span><span class="identifier">relative_weighted_tail_variate_means</span><span class="special">(</span><span class="identifier">acc3</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.3</span><span class="special">).</span><span class="identifier">begin</span><span class="special">()</span>    <span class="special">),</span> <span class="special">(</span><span class="number">0.9</span><span class="special">*</span><span class="number">26</span> <span class="special">+</span> <span class="number">1.2</span><span class="special">*</span><span class="number">2</span><span class="special">)/(</span><span class="number">0.9</span><span class="special">*</span><span class="number">50</span> <span class="special">+</span> <span class="number">1.2</span><span class="special">*</span><span class="number">20</span><span class="special">)</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="special">*(</span><span class="identifier">relative_weighted_tail_variate_means</span><span class="special">(</span><span class="identifier">acc3</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.3</span><span class="special">).</span><span class="identifier">begin</span><span class="special">()</span> <span class="special">+</span> <span class="number">1</span><span class="special">),</span> <span class="special">(</span><span class="number">0.9</span><span class="special">*</span><span class="number">4</span> <span class="special">+</span> <span class="number">1.2</span><span class="special">*</span><span class="number">2</span><span class="special">)/(</span><span class="number">0.9</span><span class="special">*</span><span class="number">50</span> <span class="special">+</span> <span class="number">1.2</span><span class="special">*</span><span class="number">20</span><span class="special">)</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="special">*(</span><span class="identifier">relative_weighted_tail_variate_means</span><span class="special">(</span><span class="identifier">acc3</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.3</span><span class="special">).</span><span class="identifier">begin</span><span class="special">()</span> <span class="special">+</span> <span class="number">2</span><span class="special">),</span> <span class="special">(</span><span class="number">0.9</span><span class="special">*</span><span class="number">17</span> <span class="special">+</span> <span class="number">1.2</span><span class="special">*</span><span class="number">2</span><span class="special">)/(</span><span class="number">0.9</span><span class="special">*</span><span class="number">50</span> <span class="special">+</span> <span class="number">1.2</span><span class="special">*</span><span class="number">20</span><span class="special">)</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="special">*(</span><span class="identifier">relative_weighted_tail_variate_means</span><span class="special">(</span><span class="identifier">acc3</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.3</span><span class="special">).</span><span class="identifier">begin</span><span class="special">()</span> <span class="special">+</span> <span class="number">3</span><span class="special">),</span> <span class="special">(</span><span class="number">0.9</span><span class="special">*</span><span class="number">3</span> <span class="special">+</span> <span class="number">1.2</span><span class="special">*</span><span class="number">14</span><span class="special">)/(</span><span class="number">0.9</span><span class="special">*</span><span class="number">50</span> <span class="special">+</span> <span class="number">1.2</span><span class="special">*</span><span class="number">20</span><span class="special">)</span> <span class="special">);</span>

<span class="comment">// check absolute risk contributions</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="special">*(</span><span class="identifier">weighted_tail_variate_means</span><span class="special">(</span><span class="identifier">acc2</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.7</span><span class="special">).</span><span class="identifier">begin</span><span class="special">()</span>    <span class="special">),</span> <span class="special">(</span><span class="number">0.8</span><span class="special">*</span><span class="number">10</span> <span class="special">+</span> <span class="number">1.0</span><span class="special">*</span><span class="number">46</span><span class="special">)/</span><span class="number">1.8</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="special">*(</span><span class="identifier">weighted_tail_variate_means</span><span class="special">(</span><span class="identifier">acc2</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.7</span><span class="special">).</span><span class="identifier">begin</span><span class="special">()</span> <span class="special">+</span> <span class="number">1</span><span class="special">),</span> <span class="special">(</span><span class="number">0.8</span><span class="special">*</span><span class="number">20</span> <span class="special">+</span> <span class="number">1.0</span><span class="special">*</span><span class="number">64</span><span class="special">)/</span><span class="number">1.8</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="special">*(</span><span class="identifier">weighted_tail_variate_means</span><span class="special">(</span><span class="identifier">acc2</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.7</span><span class="special">).</span><span class="identifier">begin</span><span class="special">()</span> <span class="special">+</span> <span class="number">2</span><span class="special">),</span> <span class="special">(</span><span class="number">0.8</span><span class="special">*</span><span class="number">30</span> <span class="special">+</span> <span class="number">1.0</span><span class="special">*</span><span class="number">40</span><span class="special">)/</span><span class="number">1.8</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="special">*(</span><span class="identifier">weighted_tail_variate_means</span><span class="special">(</span><span class="identifier">acc2</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.7</span><span class="special">).</span><span class="identifier">begin</span><span class="special">()</span> <span class="special">+</span> <span class="number">3</span><span class="special">),</span> <span class="special">(</span><span class="number">0.8</span><span class="special">*</span><span class="number">40</span> <span class="special">+</span> <span class="number">1.0</span><span class="special">*</span><span class="number">50</span><span class="special">)/</span><span class="number">1.8</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="special">*(</span><span class="identifier">weighted_tail_variate_means</span><span class="special">(</span><span class="identifier">acc4</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.3</span><span class="special">).</span><span class="identifier">begin</span><span class="special">()</span>    <span class="special">),</span> <span class="special">(</span><span class="number">0.9</span><span class="special">*</span><span class="number">26</span> <span class="special">+</span> <span class="number">1.2</span><span class="special">*</span><span class="number">2</span><span class="special">)/</span><span class="number">2.1</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="special">*(</span><span class="identifier">weighted_tail_variate_means</span><span class="special">(</span><span class="identifier">acc4</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.3</span><span class="special">).</span><span class="identifier">begin</span><span class="special">()</span> <span class="special">+</span> <span class="number">1</span><span class="special">),</span> <span class="special">(</span><span class="number">0.9</span><span class="special">*</span><span class="number">4</span> <span class="special">+</span> <span class="number">1.2</span><span class="special">*</span><span class="number">2</span><span class="special">)/</span><span class="number">2.1</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="special">*(</span><span class="identifier">weighted_tail_variate_means</span><span class="special">(</span><span class="identifier">acc4</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.3</span><span class="special">).</span><span class="identifier">begin</span><span class="special">()</span> <span class="special">+</span> <span class="number">2</span><span class="special">),</span> <span class="special">(</span><span class="number">0.9</span><span class="special">*</span><span class="number">17</span> <span class="special">+</span> <span class="number">1.2</span><span class="special">*</span><span class="number">2</span><span class="special">)/</span><span class="number">2.1</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="special">*(</span><span class="identifier">weighted_tail_variate_means</span><span class="special">(</span><span class="identifier">acc4</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.3</span><span class="special">).</span><span class="identifier">begin</span><span class="special">()</span> <span class="special">+</span> <span class="number">3</span><span class="special">),</span> <span class="special">(</span><span class="number">0.9</span><span class="special">*</span><span class="number">3</span> <span class="special">+</span> <span class="number">1.2</span><span class="special">*</span><span class="number">14</span><span class="special">)/</span><span class="number">2.1</span> <span class="special">);</span>

<span class="comment">// check relative risk contributions</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="special">*(</span><span class="identifier">relative_weighted_tail_variate_means</span><span class="special">(</span><span class="identifier">acc1</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.9</span><span class="special">).</span><span class="identifier">begin</span><span class="special">()</span>    <span class="special">),</span> <span class="number">1.0</span><span class="special">*</span><span class="number">46</span><span class="special">/(</span><span class="number">1.0</span><span class="special">*</span><span class="number">200</span><span class="special">)</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="special">*(</span><span class="identifier">relative_weighted_tail_variate_means</span><span class="special">(</span><span class="identifier">acc1</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.9</span><span class="special">).</span><span class="identifier">begin</span><span class="special">()</span> <span class="special">+</span> <span class="number">1</span><span class="special">),</span> <span class="number">1.0</span><span class="special">*</span><span class="number">64</span><span class="special">/(</span><span class="number">1.0</span><span class="special">*</span><span class="number">200</span><span class="special">)</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="special">*(</span><span class="identifier">relative_weighted_tail_variate_means</span><span class="special">(</span><span class="identifier">acc1</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.9</span><span class="special">).</span><span class="identifier">begin</span><span class="special">()</span> <span class="special">+</span> <span class="number">2</span><span class="special">),</span> <span class="number">1.0</span><span class="special">*</span><span class="number">40</span><span class="special">/(</span><span class="number">1.0</span><span class="special">*</span><span class="number">200</span><span class="special">)</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="special">*(</span><span class="identifier">relative_weighted_tail_variate_means</span><span class="special">(</span><span class="identifier">acc1</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.9</span><span class="special">).</span><span class="identifier">begin</span><span class="special">()</span> <span class="special">+</span> <span class="number">3</span><span class="special">),</span> <span class="number">1.0</span><span class="special">*</span><span class="number">50</span><span class="special">/(</span><span class="number">1.0</span><span class="special">*</span><span class="number">200</span><span class="special">)</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="special">*(</span><span class="identifier">relative_weighted_tail_variate_means</span><span class="special">(</span><span class="identifier">acc3</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.1</span><span class="special">).</span><span class="identifier">begin</span><span class="special">()</span>    <span class="special">),</span> <span class="number">1.2</span><span class="special">*</span><span class="number">2</span><span class="special">/(</span><span class="number">1.2</span><span class="special">*</span><span class="number">20</span><span class="special">)</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="special">*(</span><span class="identifier">relative_weighted_tail_variate_means</span><span class="special">(</span><span class="identifier">acc3</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.1</span><span class="special">).</span><span class="identifier">begin</span><span class="special">()</span> <span class="special">+</span> <span class="number">1</span><span class="special">),</span> <span class="number">1.2</span><span class="special">*</span><span class="number">2</span><span class="special">/(</span><span class="number">1.2</span><span class="special">*</span><span class="number">20</span><span class="special">)</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="special">*(</span><span class="identifier">relative_weighted_tail_variate_means</span><span class="special">(</span><span class="identifier">acc3</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.1</span><span class="special">).</span><span class="identifier">begin</span><span class="special">()</span> <span class="special">+</span> <span class="number">2</span><span class="special">),</span> <span class="number">1.2</span><span class="special">*</span><span class="number">2</span><span class="special">/(</span><span class="number">1.2</span><span class="special">*</span><span class="number">20</span><span class="special">)</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="special">*(</span><span class="identifier">relative_weighted_tail_variate_means</span><span class="special">(</span><span class="identifier">acc3</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.1</span><span class="special">).</span><span class="identifier">begin</span><span class="special">()</span> <span class="special">+</span> <span class="number">3</span><span class="special">),</span> <span class="number">1.2</span><span class="special">*</span><span class="number">14</span><span class="special">/(</span><span class="number">1.2</span><span class="special">*</span><span class="number">20</span><span class="special">)</span> <span class="special">);</span>

<span class="comment">// check absolute risk contributions</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="special">*(</span><span class="identifier">weighted_tail_variate_means</span><span class="special">(</span><span class="identifier">acc2</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.9</span><span class="special">).</span><span class="identifier">begin</span><span class="special">()</span>    <span class="special">),</span> <span class="number">1.0</span><span class="special">*</span><span class="number">46</span><span class="special">/</span><span class="number">1.0</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="special">*(</span><span class="identifier">weighted_tail_variate_means</span><span class="special">(</span><span class="identifier">acc2</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.9</span><span class="special">).</span><span class="identifier">begin</span><span class="special">()</span> <span class="special">+</span> <span class="number">1</span><span class="special">),</span> <span class="number">1.0</span><span class="special">*</span><span class="number">64</span><span class="special">/</span><span class="number">1.0</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="special">*(</span><span class="identifier">weighted_tail_variate_means</span><span class="special">(</span><span class="identifier">acc2</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.9</span><span class="special">).</span><span class="identifier">begin</span><span class="special">()</span> <span class="special">+</span> <span class="number">2</span><span class="special">),</span> <span class="number">1.0</span><span class="special">*</span><span class="number">40</span><span class="special">/</span><span class="number">1.0</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="special">*(</span><span class="identifier">weighted_tail_variate_means</span><span class="special">(</span><span class="identifier">acc2</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.9</span><span class="special">).</span><span class="identifier">begin</span><span class="special">()</span> <span class="special">+</span> <span class="number">3</span><span class="special">),</span> <span class="number">1.0</span><span class="special">*</span><span class="number">50</span><span class="special">/</span><span class="number">1.0</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="special">*(</span><span class="identifier">weighted_tail_variate_means</span><span class="special">(</span><span class="identifier">acc4</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.1</span><span class="special">).</span><span class="identifier">begin</span><span class="special">()</span>    <span class="special">),</span> <span class="number">1.2</span><span class="special">*</span><span class="number">2</span><span class="special">/</span><span class="number">1.2</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="special">*(</span><span class="identifier">weighted_tail_variate_means</span><span class="special">(</span><span class="identifier">acc4</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.1</span><span class="special">).</span><span class="identifier">begin</span><span class="special">()</span> <span class="special">+</span> <span class="number">1</span><span class="special">),</span> <span class="number">1.2</span><span class="special">*</span><span class="number">2</span><span class="special">/</span><span class="number">1.2</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="special">*(</span><span class="identifier">weighted_tail_variate_means</span><span class="special">(</span><span class="identifier">acc4</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.1</span><span class="special">).</span><span class="identifier">begin</span><span class="special">()</span> <span class="special">+</span> <span class="number">2</span><span class="special">),</span> <span class="number">1.2</span><span class="special">*</span><span class="number">2</span><span class="special">/</span><span class="number">1.2</span> <span class="special">);</span>
<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span> <span class="special">*(</span><span class="identifier">weighted_tail_variate_means</span><span class="special">(</span><span class="identifier">acc4</span><span class="special">,</span> <span class="identifier">quantile_probability</span> <span class="special">=</span> <span class="number">0.1</span><span class="special">).</span><span class="identifier">begin</span><span class="special">()</span> <span class="special">+</span> <span class="number">3</span><span class="special">),</span> <span class="number">1.2</span><span class="special">*</span><span class="number">14</span><span class="special">/</span><span class="number">1.2</span> <span class="special">);</span>
</pre>
<p>
          <span class="bold"><strong>See also</strong></span>
        </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
              <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/weigh_1_3_2_6_3_56_1_1_4_1.html" title="Struct template weighted_tail_variate_means_impl">weighted_tail_variate_means_impl</a></code>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.non_coherent_weighted_tail_mean" title="non_coherent_weighted_tail_mean"><code class="literal">non_coherent_weighted_tail_mean</code></a>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.tail_variate" title="tail_variate"><code class="literal">tail_variate</code></a>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.tail" title="tail"><code class="literal">tail</code></a>
            </li>
</ul></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="accumulators.user_s_guide.the_statistical_accumulators_library.weighted_variance"></a><a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.weighted_variance" title="weighted_variance and variants">weighted_variance
        <span class="emphasis"><em>and variants</em></span></a>
</h4></div></div></div>
<p>
          Lazy or iterative calculation of the weighted variance. The lazy calculation
          is associated with the <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">lazy_weighted_variance</span></code>
          feature, and the iterative calculation with the <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_variance</span></code>
          feature. Both can be extracted using the <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_variance</span><span class="special">()</span></code> extractor. For more implementation details,
          see <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/lazy__1_3_2_6_3_57_1_1_4_1.html" title="Struct template lazy_weighted_variance_impl">lazy_weighted_variance_impl</a></code>
          and <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/weighted_variance_impl.html" title="Struct template weighted_variance_impl">weighted_variance_impl</a></code>
        </p>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Result Type</span></dt>
<dd>
<p>
</p>
<pre class="programlisting"><span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">fdiv</span><span class="special">&lt;</span>
    <span class="identifier">numeric</span><span class="special">::</span><span class="identifier">functional</span><span class="special">::</span><span class="identifier">multiplies</span><span class="special">&lt;</span><em class="replaceable"><code>sample-type</code></em><span class="special">,</span> <em class="replaceable"><code>weight-type</code></em><span class="special">&gt;::</span><span class="identifier">result_type</span>
  <span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span>
<span class="special">&gt;::</span><span class="identifier">result_type</span>
</pre>
<p>
              </p>
</dd>
<dt><span class="term">Depends On</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">lazy_weighted_variance</span></code> depends
                on <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_moment</span><span class="special">&lt;</span><span class="number">2</span><span class="special">&gt;</span></code>
                and <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_mean</span></code> <br> <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_variance</span></code> depends on <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">count</span></code> and <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">immediate_weighted_mean</span></code>
              </p></dd>
<dt><span class="term">Variants</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">lazy_weighted_variance</span></code> (a.k.a.
                <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_variance</span><span class="special">(</span><span class="identifier">lazy</span><span class="special">))</span></code>
                <br> <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_variance</span></code> (a.k.a. <code class="computeroutput"><span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_variance</span><span class="special">(</span><span class="identifier">immediate</span><span class="special">)</span></code>)
              </p></dd>
<dt><span class="term">Initialization Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Accumulator Parameters</span></dt>
<dd><p>
                <code class="computeroutput"><span class="identifier">weight</span></code>
              </p></dd>
<dt><span class="term">Extractor Parameters</span></dt>
<dd><p>
                <span class="emphasis"><em>none</em></span>
              </p></dd>
<dt><span class="term">Accumulator Complexity</span></dt>
<dd><p>
                O(1)
              </p></dd>
<dt><span class="term">Extractor Complexity</span></dt>
<dd><p>
                O(1)
              </p></dd>
</dl>
</div>
<p>
          <span class="bold"><strong>Header</strong></span>
        </p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><code class="computeroutput"><a class="link" href="reference.html#header.boost.accumulators.statistics.weighted_variance_hpp" title="Header &lt;boost/accumulators/statistics/weighted_variance.hpp&gt;">boost/accumulators/statistics/weighted_variance.hpp</a></code><span class="special">&gt;</span>
</pre>
<p>
          <span class="bold"><strong>Example</strong></span>
        </p>
<pre class="programlisting"><span class="comment">// lazy weighted_variance</span>
<span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_variance</span><span class="special">(</span><span class="identifier">lazy</span><span class="special">)&gt;,</span> <span class="keyword">int</span><span class="special">&gt;</span> <span class="identifier">acc1</span><span class="special">;</span>

<span class="identifier">acc1</span><span class="special">(</span><span class="number">1</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">2</span><span class="special">);</span>    <span class="comment">//  2</span>
<span class="identifier">acc1</span><span class="special">(</span><span class="number">2</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">3</span><span class="special">);</span>    <span class="comment">//  6</span>
<span class="identifier">acc1</span><span class="special">(</span><span class="number">3</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">1</span><span class="special">);</span>    <span class="comment">//  3</span>
<span class="identifier">acc1</span><span class="special">(</span><span class="number">4</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">4</span><span class="special">);</span>    <span class="comment">// 16</span>
<span class="identifier">acc1</span><span class="special">(</span><span class="number">5</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">1</span><span class="special">);</span>    <span class="comment">//  5</span>

<span class="comment">// weighted_mean = (2+6+3+16+5) / (2+3+1+4+1) = 32 / 11 = 2.9090909090909090909090909090909</span>

<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span><span class="number">5u</span><span class="special">,</span> <span class="identifier">count</span><span class="special">(</span><span class="identifier">acc1</span><span class="special">));</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span><span class="number">2.9090909</span><span class="special">,</span> <span class="identifier">weighted_mean</span><span class="special">(</span><span class="identifier">acc1</span><span class="special">),</span> <span class="number">1e-5</span><span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span><span class="number">10.1818182</span><span class="special">,</span> <span class="identifier">accumulators</span><span class="special">::</span><span class="identifier">weighted_moment</span><span class="special">&lt;</span><span class="number">2</span><span class="special">&gt;(</span><span class="identifier">acc1</span><span class="special">),</span> <span class="number">1e-5</span><span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span><span class="number">1.7190083</span><span class="special">,</span> <span class="identifier">weighted_variance</span><span class="special">(</span><span class="identifier">acc1</span><span class="special">),</span> <span class="number">1e-5</span><span class="special">);</span>

<span class="comment">// immediate weighted_variance</span>
<span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_variance</span><span class="special">&gt;,</span> <span class="keyword">int</span><span class="special">&gt;</span> <span class="identifier">acc2</span><span class="special">;</span>

<span class="identifier">acc2</span><span class="special">(</span><span class="number">1</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">2</span><span class="special">);</span>
<span class="identifier">acc2</span><span class="special">(</span><span class="number">2</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">3</span><span class="special">);</span>
<span class="identifier">acc2</span><span class="special">(</span><span class="number">3</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">1</span><span class="special">);</span>
<span class="identifier">acc2</span><span class="special">(</span><span class="number">4</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">4</span><span class="special">);</span>
<span class="identifier">acc2</span><span class="special">(</span><span class="number">5</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="number">1</span><span class="special">);</span>

<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span><span class="number">5u</span><span class="special">,</span> <span class="identifier">count</span><span class="special">(</span><span class="identifier">acc2</span><span class="special">));</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span><span class="number">2.9090909</span><span class="special">,</span> <span class="identifier">weighted_mean</span><span class="special">(</span><span class="identifier">acc2</span><span class="special">),</span> <span class="number">1e-5</span><span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span><span class="number">1.7190083</span><span class="special">,</span> <span class="identifier">weighted_variance</span><span class="special">(</span><span class="identifier">acc2</span><span class="special">),</span> <span class="number">1e-5</span><span class="special">);</span>

<span class="comment">// check lazy and immediate variance with random numbers</span>

<span class="comment">// two random number generators</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">lagged_fibonacci607</span> <span class="identifier">rng</span><span class="special">;</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">normal_distribution</span><span class="special">&lt;&gt;</span> <span class="identifier">mean_sigma</span><span class="special">(</span><span class="number">0</span><span class="special">,</span><span class="number">1</span><span class="special">);</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">variate_generator</span><span class="special">&lt;</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">lagged_fibonacci607</span><span class="special">&amp;,</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">normal_distribution</span><span class="special">&lt;&gt;</span> <span class="special">&gt;</span> <span class="identifier">normal</span><span class="special">(</span><span class="identifier">rng</span><span class="special">,</span> <span class="identifier">mean_sigma</span><span class="special">);</span>

<span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_variance</span><span class="special">&gt;,</span> <span class="keyword">double</span> <span class="special">&gt;</span> <span class="identifier">acc_lazy</span><span class="special">;</span>
<span class="identifier">accumulator_set</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">,</span> <span class="identifier">stats</span><span class="special">&lt;</span><span class="identifier">tag</span><span class="special">::</span><span class="identifier">weighted_variance</span><span class="special">(</span><span class="identifier">immediate</span><span class="special">)&gt;,</span> <span class="keyword">double</span> <span class="special">&gt;</span> <span class="identifier">acc_immediate</span><span class="special">;</span>

<span class="keyword">for</span> <span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">i</span><span class="special">=</span><span class="number">0</span><span class="special">;</span> <span class="identifier">i</span><span class="special">&lt;</span><span class="number">10000</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
<span class="special">{</span>
    <span class="keyword">double</span> <span class="identifier">value</span> <span class="special">=</span> <span class="identifier">normal</span><span class="special">();</span>
    <span class="identifier">acc_lazy</span><span class="special">(</span><span class="identifier">value</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="identifier">rng</span><span class="special">());</span>
    <span class="identifier">acc_immediate</span><span class="special">(</span><span class="identifier">value</span><span class="special">,</span> <span class="identifier">weight</span> <span class="special">=</span> <span class="identifier">rng</span><span class="special">());</span>
<span class="special">}</span>

<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span><span class="number">1.</span><span class="special">,</span> <span class="identifier">weighted_variance</span><span class="special">(</span><span class="identifier">acc_lazy</span><span class="special">),</span> <span class="number">1.</span><span class="special">);</span>
<span class="identifier">BOOST_CHECK_CLOSE</span><span class="special">(</span><span class="number">1.</span><span class="special">,</span> <span class="identifier">weighted_variance</span><span class="special">(</span><span class="identifier">acc_immediate</span><span class="special">),</span> <span class="number">1.</span><span class="special">);</span>
</pre>
<p>
          <span class="bold"><strong>See also</strong></span>
        </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
              <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/lazy__1_3_2_6_3_57_1_1_4_1.html" title="Struct template lazy_weighted_variance_impl">lazy_weighted_variance_impl</a></code>
            </li>
<li class="listitem">
              <code class="computeroutput"><a class="link" href="../boost/accumulators/impl/weighted_variance_impl.html" title="Struct template weighted_variance_impl">weighted_variance_impl</a></code>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.count" title="count"><code class="literal">count</code></a>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.weighted_mean" title="weighted_mean and variants"><code class="literal">weighted_mean</code></a>
            </li>
<li class="listitem">
              <a class="link" href="user_s_guide.html#accumulators.user_s_guide.the_statistical_accumulators_library.weighted_moment" title="weighted_moment"><code class="literal">weighted_moment</code></a>
            </li>
</ul></div>
</div>
</div>
</div>
<div class="copyright-footer">Copyright © 2005, 2006 Eric Niebler<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
      </p>
</div>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../accumulators.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../accumulators.html"><img src="../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="acknowledgements.html"><img src="../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
